[USETUP] Deduplicate code in InstallDirectoryPage()

This commit is contained in:
Hermès Bélusca-Maïto 2024-11-09 19:15:23 +01:00
parent 8bb3e5a017
commit 5066818284
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0

View file

@ -2878,28 +2878,14 @@ InstallDirectoryPage(PINPUT_RECORD Ir)
* of an invalid path, or we are in regular setup), display the UI and allow * of an invalid path, or we are in regular setup), display the UI and allow
* the user to specify a new installation path. * the user to specify a new installation path.
*/ */
if ((RepairUpdateFlag || IsUnattendedSetup) && IsValidInstallDirectory(InstallDir)) if (RepairUpdateFlag || IsUnattendedSetup)
{ {
Status = InitDestinationPaths(&USetupData, InstallDir, InstallVolume); /* Check for the validity of the installation directory and pop up
if (!NT_SUCCESS(Status)) * an error if it is not the case. Then the user can fix it. */
{ if (IsValidInstallDirectory(InstallDir))
DPRINT1("InitDestinationPaths() failed: Status 0x%lx\n", Status); goto InitInstallDir;
MUIDisplayError(ERROR_NO_BUILD_PATH, Ir, POPUP_WAIT_ENTER);
return QUIT_PAGE;
}
/* MUIDisplayError(ERROR_DIRECTORY_NAME, Ir, POPUP_WAIT_ENTER);
* Check whether the user attempts to install ReactOS within the
* installation source directory, or in a subdirectory thereof.
* If so, fail with an error.
*/
if (RtlPrefixUnicodeString(&USetupData.SourcePath, &USetupData.DestinationPath, TRUE))
{
MUIDisplayError(ERROR_SOURCE_DIR, Ir, POPUP_WAIT_ENTER);
return INSTALL_DIRECTORY_PAGE;
}
return PREPARE_COPY_PAGE;
} }
Length = wcslen(InstallDir); Length = wcslen(InstallDir);
@ -2921,7 +2907,7 @@ InstallDirectoryPage(PINPUT_RECORD Ir)
if (ConfirmQuit(Ir)) if (ConfirmQuit(Ir))
return QUIT_PAGE; return QUIT_PAGE;
break; return INSTALL_DIRECTORY_PAGE;
} }
else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) && else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_DELETE)) /* DEL */ (Ir->Event.KeyEvent.wVirtualKeyCode == VK_DELETE)) /* DEL */
@ -2980,36 +2966,13 @@ InstallDirectoryPage(PINPUT_RECORD Ir)
{ {
CONSOLE_SetCursorType(TRUE, FALSE); CONSOLE_SetCursorType(TRUE, FALSE);
/* /* Check for the validity of the installation directory and pop up
* Check for the validity of the installation directory and pop up * an error if it is not the case. Then the user can fix it. */
* an error if it is not the case. Then the user can fix its input. if (IsValidInstallDirectory(InstallDir))
*/ goto InitInstallDir;
if (!IsValidInstallDirectory(InstallDir))
{
MUIDisplayError(ERROR_DIRECTORY_NAME, Ir, POPUP_WAIT_ENTER);
return INSTALL_DIRECTORY_PAGE;
}
Status = InitDestinationPaths(&USetupData, InstallDir, InstallVolume); MUIDisplayError(ERROR_DIRECTORY_NAME, Ir, POPUP_WAIT_ENTER);
if (!NT_SUCCESS(Status)) return INSTALL_DIRECTORY_PAGE;
{
DPRINT1("InitDestinationPaths() failed: Status 0x%lx\n", Status);
MUIDisplayError(ERROR_NO_BUILD_PATH, Ir, POPUP_WAIT_ENTER);
return QUIT_PAGE;
}
/*
* Check whether the user attempts to install ReactOS within the
* installation source directory, or in a subdirectory thereof.
* If so, fail with an error.
*/
if (RtlPrefixUnicodeString(&USetupData.SourcePath, &USetupData.DestinationPath, TRUE))
{
MUIDisplayError(ERROR_SOURCE_DIR, Ir, POPUP_WAIT_ENTER);
return INSTALL_DIRECTORY_PAGE;
}
return PREPARE_COPY_PAGE;
} }
else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x08) /* BACKSPACE */ else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x08) /* BACKSPACE */
{ {
@ -3051,7 +3014,27 @@ InstallDirectoryPage(PINPUT_RECORD Ir)
} }
} }
return INSTALL_DIRECTORY_PAGE; InitInstallDir:
Status = InitDestinationPaths(&USetupData, InstallDir, InstallVolume);
if (!NT_SUCCESS(Status))
{
DPRINT1("InitDestinationPaths() failed: Status 0x%lx\n", Status);
MUIDisplayError(ERROR_NO_BUILD_PATH, Ir, POPUP_WAIT_ENTER);
return QUIT_PAGE;
}
/*
* Check whether the user attempts to install ReactOS within the
* installation source directory, or in a subdirectory thereof.
* If so, fail with an error.
*/
if (RtlPrefixUnicodeString(&USetupData.SourcePath, &USetupData.DestinationPath, TRUE))
{
MUIDisplayError(ERROR_SOURCE_DIR, Ir, POPUP_WAIT_ENTER);
return INSTALL_DIRECTORY_PAGE;
}
return PREPARE_COPY_PAGE;
} }