mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 00:03:00 +00:00
[SETUPLIB][USETUP] Move IsValidPath() back into setuplib for reusability (#7186)
Reverts the IsValidPath() move done in commit 9c64b57dc
.
- Turn IsValidPath() into a IsValidInstallDirectory() helper function
available in the setuplib, so that it can also be used in the GUI setup.
- Introduce a IS_VALID_INSTALL_PATH_CHAR() macro.
This commit is contained in:
parent
a532a68d40
commit
785cc21598
3 changed files with 58 additions and 49 deletions
|
@ -712,6 +712,51 @@ InitSystemPartition(
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
IsValidInstallDirectory(
|
||||
_In_ PCWSTR InstallDir)
|
||||
{
|
||||
UINT i, Length;
|
||||
|
||||
Length = wcslen(InstallDir);
|
||||
|
||||
// TODO: Add check for 8.3 too.
|
||||
|
||||
/* Path must be at least 2 characters long */
|
||||
// if (Length < 2)
|
||||
// return FALSE;
|
||||
|
||||
/* Path must start with a backslash */
|
||||
// if (InstallDir[0] != L'\\')
|
||||
// return FALSE;
|
||||
|
||||
/* Path must not end with a backslash */
|
||||
if (InstallDir[Length - 1] == L'\\')
|
||||
return FALSE;
|
||||
|
||||
/* Path must not contain whitespace characters */
|
||||
for (i = 0; i < Length; i++)
|
||||
{
|
||||
if (iswspace(InstallDir[i]))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Path component must not end with a dot */
|
||||
for (i = 0; i < Length; i++)
|
||||
{
|
||||
if (InstallDir[i] == L'\\' && i > 0)
|
||||
{
|
||||
if (InstallDir[i - 1] == L'.')
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (InstallDir[Length - 1] == L'.')
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
InitDestinationPaths(
|
||||
IN OUT PUSETUP_DATA pSetupData,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue