* FILE: subsys/system/usetup/filequeue.c
* PURPOSE: File queue functions
* PROGRAMMER: Eric Kohl
+ * Casper S. Hornstrup (chorns@users.sourceforge.net)
*/
/* INCLUDES *****************************************************************/
struct _QUEUEENTRY *Prev;
struct _QUEUEENTRY *Next;
+ PWSTR SourceCabinet; /* May be NULL if file is not in a cabinet */
PWSTR SourceRootPath;
PWSTR SourcePath;
PWSTR SourceFilename;
while (Entry != NULL)
{
/* Delete all strings */
+ if (Entry->SourceCabinet != NULL)
+ RtlFreeHeap(ProcessHeap, 0, Entry->SourceCabinet);
if (Entry->SourceRootPath != NULL)
RtlFreeHeap(ProcessHeap, 0, Entry->SourceRootPath);
if (Entry->SourcePath != NULL)
BOOL
SetupQueueCopy(HSPFILEQ QueueHandle,
+ PCWSTR SourceCabinet,
PCWSTR SourceRootPath,
PCWSTR SourcePath,
PCWSTR SourceFilename,
PQUEUEENTRY Entry;
ULONG Length;
+ /* SourceCabinet may be NULL */
if (QueueHandle == NULL ||
SourceRootPath == NULL ||
SourceFilename == NULL ||
RtlZeroMemory(Entry,
sizeof(QUEUEENTRY));
+ /* Copy source cabinet if available */
+ if (SourceCabinet != NULL)
+ {
+ Length = wcslen(SourceCabinet);
+ Entry->SourceCabinet = RtlAllocateHeap(ProcessHeap,
+ 0,
+ (Length + 1) * sizeof(WCHAR));
+ if (Entry->SourceCabinet == NULL)
+ {
+ RtlFreeHeap(ProcessHeap, 0, Entry);
+ return(FALSE);
+ }
+ wcsncpy(Entry->SourceCabinet, SourceCabinet, Length);
+ Entry->SourceCabinet[Length] = (WCHAR)0;
+ }
+ else
+ {
+ Entry->SourceCabinet = NULL;
+ }
+
/* Copy source root path */
Length = wcslen(SourceRootPath);
Entry->SourceRootPath = RtlAllocateHeap(ProcessHeap,
(Length + 1) * sizeof(WCHAR));
if (Entry->SourceRootPath == NULL)
{
+ if (Entry->SourceCabinet != NULL)
+ {
+ RtlFreeHeap(ProcessHeap, 0, Entry->SourceCabinet);
+ }
RtlFreeHeap(ProcessHeap, 0, Entry);
return(FALSE);
}
(Length + 1) * sizeof(WCHAR));
if (Entry->SourcePath == NULL)
{
+ if (Entry->SourceCabinet != NULL)
+ {
+ RtlFreeHeap(ProcessHeap, 0, Entry->SourceCabinet);
+ }
RtlFreeHeap(ProcessHeap, 0, Entry->SourceRootPath);
RtlFreeHeap(ProcessHeap, 0, Entry);
return(FALSE);
(Length + 1) * sizeof(WCHAR));
if (Entry->SourceFilename == NULL)
{
+ if (Entry->SourceCabinet != NULL)
+ {
+ RtlFreeHeap(ProcessHeap, 0, Entry->SourceCabinet);
+ }
RtlFreeHeap(ProcessHeap, 0, Entry->SourceRootPath);
RtlFreeHeap(ProcessHeap, 0, Entry->SourcePath);
RtlFreeHeap(ProcessHeap, 0, Entry);
(Length + 1) * sizeof(WCHAR));
if (Entry->TargetDirectory == NULL)
{
+ if (Entry->SourceCabinet != NULL)
+ {
+ RtlFreeHeap(ProcessHeap, 0, Entry->SourceCabinet);
+ }
RtlFreeHeap(ProcessHeap, 0, Entry->SourceRootPath);
RtlFreeHeap(ProcessHeap, 0, Entry->SourcePath);
RtlFreeHeap(ProcessHeap, 0, Entry->SourceFilename);
(Length + 1) * sizeof(WCHAR));
if (Entry->TargetFilename == NULL)
{
+ if (Entry->SourceCabinet != NULL)
+ {
+ RtlFreeHeap(ProcessHeap, 0, Entry->SourceCabinet);
+ }
RtlFreeHeap(ProcessHeap, 0, Entry->SourceRootPath);
RtlFreeHeap(ProcessHeap, 0, Entry->SourcePath);
RtlFreeHeap(ProcessHeap, 0, Entry->SourceFilename);
PSP_FILE_CALLBACK MsgHandler,
PVOID Context)
{
+ WCHAR CabinetName[MAX_PATH];
PFILEQUEUEHEADER QueueHeader;
PQUEUEENTRY Entry;
NTSTATUS Status;
Entry = QueueHeader->CopyHead;
while (Entry != NULL)
{
- /* Build the full source path */
wcscpy(FileSrcPath, Entry->SourceRootPath);
if (Entry->SourcePath != NULL)
wcscat(FileSrcPath, Entry->SourcePath);
wcscat(FileDstPath, L"\\");
wcscat(FileDstPath, Entry->TargetDirectory);
}
- wcscat(FileDstPath, L"\\");
- if (Entry->TargetFilename != NULL)
- wcscat(FileDstPath, Entry->TargetFilename);
- else
- wcscat(FileDstPath, Entry->SourceFilename);
+
+ /* Use only the destination path if the file is in a cabinet */
+ if (Entry->SourceCabinet == NULL)
+ {
+ wcscat(FileDstPath, L"\\");
+ if (Entry->TargetFilename != NULL)
+ wcscat(FileDstPath, Entry->TargetFilename);
+ else
+ wcscat(FileDstPath, Entry->SourceFilename);
+ }
/* FIXME: Do it! */
DPRINT("'%S' ==> '%S'\n",
(PVOID)Entry->SourceFilename,
(PVOID)FILEOP_COPY);
- /* Copy the file */
- Status = SetupCopyFile(FileSrcPath, FileDstPath);
+ if (Entry->SourceCabinet != NULL)
+ {
+ /* Extract the file */
+ wcscpy(CabinetName, Entry->SourceRootPath);
+ if (Entry->SourcePath != NULL)
+ wcscat(CabinetName, Entry->SourcePath);
+ wcscat(CabinetName, L"\\");
+ wcscat(CabinetName, Entry->SourceCabinet);
+ Status = SetupExtractFile(CabinetName, Entry->SourceFilename, FileDstPath);
+ }
+ else
+ {
+ /* Copy the file */
+ Status = SetupCopyFile(FileSrcPath, FileDstPath);
+ }
if (!NT_SUCCESS(Status))
{
MsgHandler(Context,