X-Git-Url: http://git.jankratochvil.net/?p=reactos.git;a=blobdiff_plain;f=subsys%2Fsystem%2Fusetup%2Ffilesup.c;fp=subsys%2Fsystem%2Fusetup%2Ffilesup.c;h=2a15a161cf11e557720ae98cf4e060ac21a1a38b;hp=f735dc02fc5f0a9902a212c358bf01e26b74a366;hb=a3df8bf1429570e0bd6c6428f6ed80073578cf4b;hpb=7c0db166f81fbe8c8b913d7f26048e337d383605 diff --git a/subsys/system/usetup/filesup.c b/subsys/system/usetup/filesup.c index f735dc0..2a15a16 100644 --- a/subsys/system/usetup/filesup.c +++ b/subsys/system/usetup/filesup.c @@ -22,6 +22,7 @@ * FILE: subsys/system/usetup/filesup.c * PURPOSE: File support functions * PROGRAMMER: Eric Kohl + * Casper S. Hornstrup (chorns@users.sourceforge.net) */ /* INCLUDES *****************************************************************/ @@ -31,11 +32,15 @@ #include "usetup.h" #include "filesup.h" +#include "cabinet.h" /* FUNCTIONS ****************************************************************/ +static BOOLEAN HasCurrentCabinet = FALSE; +static WCHAR CurrentCabinetName[MAX_PATH]; + NTSTATUS CreateDirectory(PWCHAR DirectoryName) { @@ -111,7 +116,6 @@ SetupCopyFile(PWCHAR SourceFileName, FILE_SYNCHRONOUS_IO_ALERT | FILE_SEQUENTIAL_ONLY); if (!NT_SUCCESS(Status)) { -CHECKPOINT1; return(Status); } @@ -122,7 +126,6 @@ CHECKPOINT1; FileStandardInformation); if (!NT_SUCCESS(Status)) { -CHECKPOINT1; NtClose(FileHandleSource); return(Status); } @@ -133,7 +136,6 @@ CHECKPOINT1; FileBasicInformation); if (!NT_SUCCESS(Status)) { -CHECKPOINT1; NtClose(FileHandleSource); return(Status); } @@ -160,7 +162,6 @@ CHECKPOINT1; 0); if (!NT_SUCCESS(Status)) { -CHECKPOINT1; NtClose(FileHandleSource); return(Status); } @@ -174,7 +175,6 @@ CHECKPOINT1; FilePositionInformation); if (!NT_SUCCESS(Status)) { -CHECKPOINT1; NtClose(FileHandleSource); NtClose(FileHandleDest); return(Status); @@ -187,7 +187,6 @@ CHECKPOINT1; FilePositionInformation); if (!NT_SUCCESS(Status)) { -CHECKPOINT1; NtClose(FileHandleSource); NtClose(FileHandleDest); return(Status); @@ -206,7 +205,6 @@ CHECKPOINT1; PAGE_READWRITE); if (!NT_SUCCESS(Status)) { -CHECKPOINT1; NtClose(FileHandleSource); NtClose(FileHandleDest); return(Status); @@ -234,7 +232,6 @@ CHECKPOINT1; DPRINT("STATUS_END_OF_FILE\n"); break; } -CHECKPOINT1; NtClose(FileHandleSource); NtClose(FileHandleDest); return(Status); @@ -253,7 +250,6 @@ CHECKPOINT1; NULL); if (!NT_SUCCESS(Status)) { -CHECKPOINT1; NtFreeVirtualMemory(NtCurrentProcess(), (PVOID *)&Buffer, &RegionSize, @@ -283,6 +279,65 @@ CHECKPOINT1; } +NTSTATUS +SetupExtractFile(PWCHAR CabinetFileName, + PWCHAR SourceFileName, + PWCHAR DestinationPathName) +{ + ULONG CabStatus; + + DPRINT("SetupExtractFile(CabinetFileName %S, SourceFileName %S, DestinationPathName %S)\n", + CabinetFileName, SourceFileName, DestinationPathName); + + if (HasCurrentCabinet) + { + DPRINT("CurrentCabinetName: %S\n", CurrentCabinetName); + } + + if ((HasCurrentCabinet) && (wcscmp(CabinetFileName, CurrentCabinetName) == 0)) + { + DPRINT("Using same cabinet as last time\n"); + } + else + { + DPRINT("Using new cabinet\n"); + + if (HasCurrentCabinet) + { + CabinetCleanup(); + } + + wcscpy(CurrentCabinetName, CabinetFileName); + + CabinetInitialize(); + CabinetSetEventHandlers(NULL, NULL, NULL); + CabinetSetCabinetName(CabinetFileName); + + CabStatus = CabinetOpen(); + if (CabStatus == CAB_STATUS_SUCCESS) + { + DPRINT("Opened cabinet %S\n", CabinetGetCabinetName()); + HasCurrentCabinet = TRUE; + } + else + { + DPRINT("Cannot open cabinet (%d)\n", CabStatus); + return STATUS_UNSUCCESSFUL; + } + } + + CabinetSetDestinationPath(DestinationPathName); + CabStatus = CabinetExtractFile(SourceFileName); + if (CabStatus != CAB_STATUS_SUCCESS) + { + DPRINT("Cannot extract file %S (%d)\n", SourceFileName, CabStatus); + return STATUS_UNSUCCESSFUL; + } + + return STATUS_SUCCESS; +} + + BOOLEAN DoesFileExist(PWSTR PathName, PWSTR FileName) @@ -319,7 +374,6 @@ DoesFileExist(PWSTR PathName, FILE_SYNCHRONOUS_IO_ALERT); if (!NT_SUCCESS(Status)) { -CHECKPOINT1; return(FALSE); }