-
-static BOOLEAN
-AddSectionToCopyQueueCab(HINF InfFile,
- PCWSTR SectionName,
- PCWSTR SourceCabinet,
- PCUNICODE_STRING DestinationPath,
- PINPUT_RECORD Ir)
-{
- INFCONTEXT FilesContext;
- INFCONTEXT DirContext;
- PCWSTR FileKeyName;
- PCWSTR FileKeyValue;
- PCWSTR DirKeyValue;
- PCWSTR TargetFileName;
- WCHAR FileDstPath[MAX_PATH];
-
- /*
- * This code enumerates the list of files in reactos.dff / reactos.inf
- * that need to be extracted from reactos.cab and be installed in their
- * respective directories.
- */
-
- /* Search for the SectionName section */
- if (!SpInfFindFirstLine(InfFile, SectionName, NULL, &FilesContext))
- {
- MUIDisplayError(ERROR_TXTSETUP_SECTION, Ir, POPUP_WAIT_ENTER, SectionName);
- return FALSE;
- }
-
- /*
- * Enumerate the files in the section and add them to the file queue.
- */
- do
- {
- /* Get source file name and target directory id */
- if (!INF_GetData(&FilesContext, &FileKeyName, &FileKeyValue))
- {
- /* FIXME: Handle error! */
- DPRINT1("INF_GetData() failed\n");
- break;
- }
-
- /* Get optional target file name */
- if (!INF_GetDataField(&FilesContext, 2, &TargetFileName))
- TargetFileName = NULL;
-
- DPRINT("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName, FileKeyValue);
-
- /* Lookup target directory */
- if (!SpInfFindFirstLine(InfFile, L"Directories", FileKeyValue, &DirContext))
- {
- /* FIXME: Handle error! */
- DPRINT1("SetupFindFirstLine() failed\n");
- INF_FreeData(FileKeyName);
- INF_FreeData(FileKeyValue);
- INF_FreeData(TargetFileName);
- break;
- }
-
- INF_FreeData(FileKeyValue);
-
- if (!INF_GetData(&DirContext, NULL, &DirKeyValue))
- {
- /* FIXME: Handle error! */
- DPRINT1("INF_GetData() failed\n");
- INF_FreeData(FileKeyName);
- INF_FreeData(TargetFileName);
- break;
- }
-
-#if 1 // HACK moved! (r66604)
- {
- ULONG Length = wcslen(DirKeyValue);
- if ((Length > 0) && (DirKeyValue[Length - 1] == L'\\'))
- Length--;
- *((PWSTR)DirKeyValue + Length) = UNICODE_NULL;
- }
-
- /* Build the full target path */
- RtlStringCchCopyW(FileDstPath, ARRAYSIZE(FileDstPath),
- USetupData.DestinationRootPath.Buffer);
- if (DirKeyValue[0] == UNICODE_NULL)
- {
- /* Installation path */
-
- /* Add the installation path */
- ConcatPaths(FileDstPath, ARRAYSIZE(FileDstPath), 1, USetupData.InstallPath.Buffer);
- }
- else if (DirKeyValue[0] == L'\\')
- {
- /* Absolute path */
- // if (DirKeyValue[1] != UNICODE_NULL)
- ConcatPaths(FileDstPath, ARRAYSIZE(FileDstPath), 1, DirKeyValue);
- }
- else // if (DirKeyValue[0] != L'\\')
- {
- /* Path relative to the installation path */
-
- /* Add the installation path */
- ConcatPaths(FileDstPath, ARRAYSIZE(FileDstPath), 2,
- USetupData.InstallPath.Buffer, DirKeyValue);
- }
-#endif
-
- if (!SpFileQueueCopy((HSPFILEQ)USetupData.SetupFileQueue,
- USetupData.SourceRootPath.Buffer,
- USetupData.SourceRootDir.Buffer,
- FileKeyName,
- NULL,
- SourceCabinet,
- NULL,
- FileDstPath,
- TargetFileName,
- 0 /* FIXME */))
- {
- /* FIXME: Handle error! */
- DPRINT1("SpFileQueueCopy() failed\n");
- }
-
- INF_FreeData(FileKeyName);
- INF_FreeData(TargetFileName);
- INF_FreeData(DirKeyValue);
- } while (SpInfFindNextLine(&FilesContext, &FilesContext));
-
- return TRUE;
-}
-
-
-static BOOLEAN
-AddSectionToCopyQueue(HINF InfFile,
- PCWSTR SectionName,
- PCWSTR SourceCabinet,
- PCUNICODE_STRING DestinationPath,
- PINPUT_RECORD Ir)
-{
- INFCONTEXT FilesContext;
- INFCONTEXT DirContext;
- PCWSTR FileKeyName;
- PCWSTR FileKeyValue;
- PCWSTR DirKeyValue;
- PCWSTR TargetFileName;
- WCHAR CompleteOrigDirName[512]; // FIXME: MAX_PATH is not enough?
- WCHAR FileDstPath[MAX_PATH];
-
- if (SourceCabinet)
- return AddSectionToCopyQueueCab(InfFile, L"SourceFiles", SourceCabinet, DestinationPath, Ir);
-
- /*
- * This code enumerates the list of files in txtsetup.sif
- * that need to be installed in their respective directories.
- */
-
- /* Search for the SectionName section */
- if (!SpInfFindFirstLine(InfFile, SectionName, NULL, &FilesContext))
- {
- MUIDisplayError(ERROR_TXTSETUP_SECTION, Ir, POPUP_WAIT_ENTER, SectionName);
- return FALSE;
- }
-
- /*
- * Enumerate the files in the section and add them to the file queue.
- */
- do
- {
- /* Get source file name */
- if (!INF_GetDataField(&FilesContext, 0, &FileKeyName))
- {
- /* FIXME: Handle error! */
- DPRINT1("INF_GetData() failed\n");
- break;
- }
-
- /* Get target directory id */
- if (!INF_GetDataField(&FilesContext, 13, &FileKeyValue))
- {
- /* FIXME: Handle error! */
- DPRINT1("INF_GetData() failed\n");
- INF_FreeData(FileKeyName);
- break;
- }
-
- /* Get optional target file name */
- if (!INF_GetDataField(&FilesContext, 11, &TargetFileName))
- TargetFileName = NULL;
- else if (!*TargetFileName)
- TargetFileName = NULL;
-
- DPRINT("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName, FileKeyValue);
-
- /* Lookup target directory */
- if (!SpInfFindFirstLine(InfFile, L"Directories", FileKeyValue, &DirContext))
- {
- /* FIXME: Handle error! */
- DPRINT1("SetupFindFirstLine() failed\n");
- INF_FreeData(FileKeyName);
- INF_FreeData(FileKeyValue);
- INF_FreeData(TargetFileName);
- break;
- }
-
- INF_FreeData(FileKeyValue);
-
- if (!INF_GetData(&DirContext, NULL, &DirKeyValue))
- {
- /* FIXME: Handle error! */
- DPRINT1("INF_GetData() failed\n");
- INF_FreeData(FileKeyName);
- INF_FreeData(TargetFileName);
- break;
- }
-
- if ((DirKeyValue[0] == UNICODE_NULL) || (DirKeyValue[0] == L'\\' && DirKeyValue[1] == UNICODE_NULL))
- {
- /* Installation path */
- DPRINT("InstallationPath: '%S'\n", DirKeyValue);
-
- RtlStringCchCopyW(CompleteOrigDirName, ARRAYSIZE(CompleteOrigDirName),
- USetupData.SourceRootDir.Buffer);
-
- DPRINT("InstallationPath(2): '%S'\n", CompleteOrigDirName);
- }
- else if (DirKeyValue[0] == L'\\')
- {
- /* Absolute path */
- DPRINT("AbsolutePath: '%S'\n", DirKeyValue);
-
- RtlStringCchCopyW(CompleteOrigDirName, ARRAYSIZE(CompleteOrigDirName),
- DirKeyValue);
-
- DPRINT("AbsolutePath(2): '%S'\n", CompleteOrigDirName);
- }
- else // if (DirKeyValue[0] != L'\\')
- {
- /* Path relative to the installation path */
- DPRINT("RelativePath: '%S'\n", DirKeyValue);
-
- CombinePaths(CompleteOrigDirName, ARRAYSIZE(CompleteOrigDirName), 2,
- USetupData.SourceRootDir.Buffer, DirKeyValue);
-
- DPRINT("RelativePath(2): '%S'\n", CompleteOrigDirName);
- }
-
-#if 1 // HACK moved! (r66604)
- {
- ULONG Length = wcslen(DirKeyValue);
- if ((Length > 0) && (DirKeyValue[Length - 1] == L'\\'))
- Length--;
- *((PWSTR)DirKeyValue + Length) = UNICODE_NULL;
- }
-
- /* Build the full target path */
- RtlStringCchCopyW(FileDstPath, ARRAYSIZE(FileDstPath),
- USetupData.DestinationRootPath.Buffer);
- if (DirKeyValue[0] == UNICODE_NULL)
- {
- /* Installation path */
-
- /* Add the installation path */
- ConcatPaths(FileDstPath, ARRAYSIZE(FileDstPath), 1, USetupData.InstallPath.Buffer);
- }
- else if (DirKeyValue[0] == L'\\')
- {
- /* Absolute path */
- // if (DirKeyValue[1] != UNICODE_NULL)
- ConcatPaths(FileDstPath, ARRAYSIZE(FileDstPath), 1, DirKeyValue);
- }
- else // if (DirKeyValue[0] != L'\\')
- {
- /* Path relative to the installation path */
-
- /* Add the installation path */
- ConcatPaths(FileDstPath, ARRAYSIZE(FileDstPath), 2,
- USetupData.InstallPath.Buffer, DirKeyValue);
- }
-#endif
-
- if (!SpFileQueueCopy((HSPFILEQ)USetupData.SetupFileQueue,
- USetupData.SourceRootPath.Buffer,
- CompleteOrigDirName,
- FileKeyName,
- NULL,
- SourceCabinet,
- NULL,
- FileDstPath,
- TargetFileName,
- 0 /* FIXME */))
- {
- /* FIXME: Handle error! */
- DPRINT1("SpFileQueueCopy() failed\n");
- }
-
- INF_FreeData(FileKeyName);
- INF_FreeData(TargetFileName);
- INF_FreeData(DirKeyValue);
- } while (SpInfFindNextLine(&FilesContext, &FilesContext));
-
- return TRUE;
-}
-
-
-static BOOLEAN
-PrepareCopyPageInfFile(HINF InfFile,
- PCWSTR SourceCabinet,
- PINPUT_RECORD Ir)
-{
- NTSTATUS Status;
- INFCONTEXT DirContext;
- PWCHAR AdditionalSectionName = NULL;
- PCWSTR DirKeyValue;
- WCHAR PathBuffer[MAX_PATH];
-
- /* Add common files */
- if (!AddSectionToCopyQueue(InfFile, L"SourceDisksFiles", SourceCabinet, &USetupData.DestinationPath, Ir))
- return FALSE;
-
- /* Add specific files depending of computer type */
- if (SourceCabinet == NULL)
- {
- if (!ProcessComputerFiles(InfFile, USetupData.ComputerList, &AdditionalSectionName))
- return FALSE;
-
- if (AdditionalSectionName)
- {
- if (!AddSectionToCopyQueue(InfFile, AdditionalSectionName, SourceCabinet, &USetupData.DestinationPath, Ir))
- return FALSE;
- }
- }
-
- /* Create directories */
-
- /*
- * FIXME:
- * Copying files to USetupData.DestinationRootPath should be done from within
- * the SystemPartitionFiles section.
- * At the moment we check whether we specify paths like '\foo' or '\\' for that.
- * For installing to USetupData.DestinationPath specify just '\' .
- */
-
- /* Get destination path */
- RtlStringCchCopyW(PathBuffer, ARRAYSIZE(PathBuffer), USetupData.DestinationPath.Buffer);
-
- DPRINT("FullPath(1): '%S'\n", PathBuffer);
-
- /* Create the install directory */
- Status = SetupCreateDirectory(PathBuffer);
- if (!NT_SUCCESS(Status) && Status != STATUS_OBJECT_NAME_COLLISION)
- {
- DPRINT1("Creating directory '%S' failed: Status = 0x%08lx\n", PathBuffer, Status);
- MUIDisplayError(ERROR_CREATE_INSTALL_DIR, Ir, POPUP_WAIT_ENTER);
- return FALSE;
- }
-
- /* Search for the 'Directories' section */
- if (!SpInfFindFirstLine(InfFile, L"Directories", NULL, &DirContext))
- {
- if (SourceCabinet)
- MUIDisplayError(ERROR_CABINET_SECTION, Ir, POPUP_WAIT_ENTER, L"Directories");
- else
- MUIDisplayError(ERROR_TXTSETUP_SECTION, Ir, POPUP_WAIT_ENTER, L"Directories");
-
- return FALSE;
- }
-
- /* Enumerate the directory values and create the subdirectories */
- do
- {
- if (!INF_GetData(&DirContext, NULL, &DirKeyValue))
- {
- DPRINT1("break\n");
- break;
- }
-
- if ((DirKeyValue[0] == UNICODE_NULL) || (DirKeyValue[0] == L'\\' && DirKeyValue[1] == UNICODE_NULL))
- {
- /* Installation path */
- DPRINT("InstallationPath: '%S'\n", DirKeyValue);
-
- RtlStringCchCopyW(PathBuffer, ARRAYSIZE(PathBuffer),
- USetupData.DestinationPath.Buffer);
-
- DPRINT("InstallationPath(2): '%S'\n", PathBuffer);
- }
- else if (DirKeyValue[0] == L'\\')
- {
- /* Absolute path */
- DPRINT("AbsolutePath: '%S'\n", DirKeyValue);
-
- CombinePaths(PathBuffer, ARRAYSIZE(PathBuffer), 2,
- USetupData.DestinationRootPath.Buffer, DirKeyValue);
-
- DPRINT("AbsolutePath(2): '%S'\n", PathBuffer);
-
- Status = SetupCreateDirectory(PathBuffer);
- if (!NT_SUCCESS(Status) && Status != STATUS_OBJECT_NAME_COLLISION)
- {
- INF_FreeData(DirKeyValue);
- DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer, Status);
- MUIDisplayError(ERROR_CREATE_DIR, Ir, POPUP_WAIT_ENTER);
- return FALSE;
- }
- }
- else // if (DirKeyValue[0] != L'\\')
- {
- /* Path relative to the installation path */
- DPRINT("RelativePath: '%S'\n", DirKeyValue);
-
- CombinePaths(PathBuffer, ARRAYSIZE(PathBuffer), 2,
- USetupData.DestinationPath.Buffer, DirKeyValue);
-
- DPRINT("RelativePath(2): '%S'\n", PathBuffer);
-
- Status = SetupCreateDirectory(PathBuffer);
- if (!NT_SUCCESS(Status) && Status != STATUS_OBJECT_NAME_COLLISION)
- {
- INF_FreeData(DirKeyValue);
- DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer, Status);
- MUIDisplayError(ERROR_CREATE_DIR, Ir, POPUP_WAIT_ENTER);
- return FALSE;
- }
- }
-
- INF_FreeData(DirKeyValue);
- } while (SpInfFindNextLine(&DirContext, &DirContext));
-
- return TRUE;
-}
-
-