https://git.reactos.org/?p=reactos.git;a=commitdiff;h=849fe9f4eb11707d2f205271aaa77f0d80cb8064

commit 849fe9f4eb11707d2f205271aaa77f0d80cb8064
Author:     Eric Kohl <[email protected]>
AuthorDate: Tue May 15 18:11:12 2018 +0200
Commit:     Eric Kohl <[email protected]>
CommitDate: Tue May 15 18:11:12 2018 +0200

    [USETUP] Simplify the unattended code path in the install directory page 
and verify the unattended install path.
---
 base/setup/usetup/filesup.c          |  7 ++--
 base/setup/usetup/filesup.h          |  3 +-
 base/setup/usetup/interface/usetup.c | 65 +++++++++++++++---------------------
 3 files changed, 32 insertions(+), 43 deletions(-)

diff --git a/base/setup/usetup/filesup.c b/base/setup/usetup/filesup.c
index 4dfd7d40b6..a325df8e2a 100644
--- a/base/setup/usetup/filesup.c
+++ b/base/setup/usetup/filesup.c
@@ -133,10 +133,11 @@ DoesPathExist(
 
 BOOLEAN
 IsValidPath(
-    PWCHAR InstallDir,
-    ULONG Length)
+    PWCHAR InstallDir)
 {
-    UINT i;
+    UINT i, Length;
+
+    Length = wcslen(InstallDir);
 
     // TODO: Add check for 8.3 too.
 
diff --git a/base/setup/usetup/filesup.h b/base/setup/usetup/filesup.h
index 85790e4c66..e09a08c673 100644
--- a/base/setup/usetup/filesup.h
+++ b/base/setup/usetup/filesup.h
@@ -48,7 +48,6 @@ DoesFileExist(
 
 BOOLEAN
 IsValidPath(
-    PWCHAR InstallDir,
-    ULONG Length);
+    PWCHAR InstallDir);
 
 /* EOF */
diff --git a/base/setup/usetup/interface/usetup.c 
b/base/setup/usetup/interface/usetup.c
index dbd024d076..2cbab22f0e 100644
--- a/base/setup/usetup/interface/usetup.c
+++ b/base/setup/usetup/interface/usetup.c
@@ -3257,24 +3257,11 @@ CheckFileSystemPage(PINPUT_RECORD Ir)
 }
 
 
-/*
- * Displays the InstallDirectoryPage1.
- *
- * Next pages:
- *  PrepareCopyPage (At once)
- *
- * SIDEEFFECTS
- *  Inits DestinationRootPath
- *  Inits DestinationPath
- *  Inits DestinationArcPath
- *
- * RETURNS
- *   Number of the next page.
- */
-static PAGE_NUMBER
-InstallDirectoryPage1(PWCHAR InstallDir,
-                      PDISKENTRY DiskEntry,
-                      PPARTENTRY PartEntry)
+static
+VOID
+BuildInstallPaths(PWCHAR InstallDir,
+                  PDISKENTRY DiskEntry,
+                  PPARTENTRY PartEntry)
 {
     WCHAR PathBuffer[MAX_PATH];
 
@@ -3313,8 +3300,6 @@ InstallDirectoryPage1(PWCHAR InstallDir,
 
     wcscat(PathBuffer, InstallDir);
     RtlCreateUnicodeString(&DestinationArcPath, PathBuffer);
-
-    return PREPARE_COPY_PAGE;
 }
 
 
@@ -3356,9 +3341,21 @@ InstallDirectoryPage(PINPUT_RECORD Ir)
     PartEntry = PartitionList->CurrentPartition;
 
     if (IsUnattendedSetup)
-        wcscpy(InstallDir, UnattendInstallationDirectory);
-    else
-        wcscpy(InstallDir, L"\\ReactOS");
+    {
+        if (!IsValidPath(UnattendInstallationDirectory))
+        {
+            /* FIXME: Log the error? */
+            return QUIT_PAGE;
+        }
+
+        BuildInstallPaths(UnattendInstallationDirectory,
+                          DiskEntry,
+                          PartEntry);
+
+        return PREPARE_COPY_PAGE;
+    }
+
+    wcscpy(InstallDir, L"\\ReactOS");
 
     Length = wcslen(InstallDir);
     Pos = Length;
@@ -3367,17 +3364,6 @@ InstallDirectoryPage(PINPUT_RECORD Ir)
     CONSOLE_SetCursorType(TRUE, TRUE);
     MUIDisplayPage(INSTALL_DIRECTORY_PAGE);
 
-    // FIXME: Check the validity of the InstallDir; however what to do
-    // if it is invalid but we are in unattended setup? (case of somebody
-    // specified an invalid installation directory in the unattended file).
-
-    if (IsUnattendedSetup)
-    {
-        return InstallDirectoryPage1(InstallDir,
-                                     DiskEntry,
-                                     PartEntry);
-    }
-
     while (TRUE)
     {
         CONSOLE_ConInKey(Ir);
@@ -3446,14 +3432,17 @@ InstallDirectoryPage(PINPUT_RECORD Ir)
              * Check for the validity of the installation directory and pop up
              * an error if it is not the case. Then the user can fix its input.
              */
-            if (!IsValidPath(InstallDir, Length))
+            if (!IsValidPath(InstallDir))
             {
                 MUIDisplayError(ERROR_DIRECTORY_NAME, Ir, POPUP_WAIT_ENTER);
                 return INSTALL_DIRECTORY_PAGE;
             }
-            return InstallDirectoryPage1(InstallDir,
-                                         DiskEntry,
-                                         PartEntry);
+
+            BuildInstallPaths(InstallDir,
+                              DiskEntry,
+                              PartEntry);
+
+            return PREPARE_COPY_PAGE;
         }
         else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x08) /* BACKSPACE */
         {

Reply via email to