Author: cgutman
Date: Fri Dec 9 14:51:57 2011
New Revision: 54624
URL:
http://svn.reactos.org/svn/reactos?rev=54624&view=rev
Log:
[USETUP]
- Optimize cabinet file processing by finding files sequentially instead of starting from
the beginning each time
Modified:
trunk/reactos/base/setup/usetup/cabinet.c
trunk/reactos/base/setup/usetup/cabinet.h
trunk/reactos/base/setup/usetup/filesup.c
Modified: trunk/reactos/base/setup/usetup/cabinet.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/setup/usetup/cabinet.…
==============================================================================
--- trunk/reactos/base/setup/usetup/cabinet.c [iso-8859-1] (original)
+++ trunk/reactos/base/setup/usetup/cabinet.c [iso-8859-1] Fri Dec 9 14:51:57 2011
@@ -694,6 +694,23 @@
}
/*
+ * FUNCTION: Finds the next file in the cabinet that matches a search criteria
+ * ARGUMENTS:
+ * FileName = Pointer to search criteria
+ * Search = Pointer to search structure
+ * RETURNS:
+ * Status of operation
+ */
+ULONG
+CabinetFindNextFileSequential(PWCHAR FileName,
+ PCAB_SEARCH Search)
+{
+ DPRINT("CabinetFindNextFileSequential( FileName = %S )\n", FileName);
+ wcsncpy(Search->Search, FileName, MAX_PATH);
+ return CabinetFindNext(Search);
+}
+
+/*
* FUNCTION: Finds next file in the cabinet that matches a search criteria
* ARGUMENTS:
* Search = Pointer to search structure
@@ -703,7 +720,6 @@
ULONG
CabinetFindNext(PCAB_SEARCH Search)
{
- ULONG Status;
PCFFILE Prev;
ANSI_STRING AnsiString;
UNICODE_STRING UnicodeString;
@@ -766,33 +782,9 @@
Search->Index++;
if (Search->Index >= PCABHeader->FileCount)
{
- /* we have reached the end of this cabinet, try to open the next */
+ /* we have reached the end of this cabinet */
DPRINT("End of cabinet reached\n");
- if (wcslen(DiskNext) > 0)
- {
- CloseCabinet();
-
- CabinetSetCabinetName(CabinetNext);
- wcscpy(Search->Cabinet, CabinetName);
-
- if (DiskChangeHandler != NULL)
- {
- DiskChangeHandler(CabinetNext, DiskNext);
- }
-
- Status = CabinetOpen();
- if (Status != CAB_STATUS_SUCCESS)
- return Status;
- }
- else
- {
- return CAB_STATUS_NOFILE;
- }
-
- /* starting new search or cabinet */
- Search->File = (PCFFILE)(FileBuffer + PCABHeader->FileTableOffset);
- Search->Index = 0;
- Prev = 0;
+ return CAB_STATUS_NOFILE;
}
else
Search->File = (PCFFILE)(strchr((char *)(Search->File + 1), 0) + 1);
Modified: trunk/reactos/base/setup/usetup/cabinet.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/setup/usetup/cabinet.…
==============================================================================
--- trunk/reactos/base/setup/usetup/cabinet.h [iso-8859-1] (original)
+++ trunk/reactos/base/setup/usetup/cabinet.h [iso-8859-1] Fri Dec 9 14:51:57 2011
@@ -191,8 +191,10 @@
VOID CabinetClose(VOID);
/* Locates the first file in the current cabinet file that matches a search criteria */
ULONG CabinetFindFirst(PWCHAR FileName, PCAB_SEARCH Search);
-/* Locates the next file in the current cabinet file */
+/* Locates the next file that matches the current search criteria */
ULONG CabinetFindNext(PCAB_SEARCH Search);
+/* Locates the next file in the current cabinet file sequentially */
+ULONG CabinetFindNextFileSequential(PWCHAR FileName, PCAB_SEARCH Search);
/* Extracts a file from the current cabinet file */
ULONG CabinetExtractFile(PCAB_SEARCH Search);
/* Select codec engine to use */
Modified: trunk/reactos/base/setup/usetup/filesup.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/setup/usetup/filesup.…
==============================================================================
--- trunk/reactos/base/setup/usetup/filesup.c [iso-8859-1] (original)
+++ trunk/reactos/base/setup/usetup/filesup.c [iso-8859-1] Fri Dec 9 14:51:57 2011
@@ -35,6 +35,7 @@
static BOOLEAN HasCurrentCabinet = FALSE;
static WCHAR CurrentCabinetName[MAX_PATH];
+static CAB_SEARCH Search;
NTSTATUS
SetupCreateDirectory(PWCHAR DirectoryName)
@@ -275,7 +276,6 @@
PWCHAR DestinationPathName)
{
ULONG CabStatus;
- CAB_SEARCH Search;
DPRINT("SetupExtractFile(CabinetFileName %S, SourceFileName %S,
DestinationPathName %S)\n",
CabinetFileName, SourceFileName, DestinationPathName);
@@ -288,6 +288,16 @@
if ((HasCurrentCabinet) && (wcscmp(CabinetFileName, CurrentCabinetName) == 0))
{
DPRINT("Using same cabinet as last time\n");
+
+ /* Use our last location because the files should be sequential */
+ CabStatus = CabinetFindNextFileSequential(SourceFileName, &Search);
+ if (CabStatus != CAB_STATUS_SUCCESS)
+ {
+ DPRINT("Sequential miss on file: %S\n", SourceFileName);
+
+ /* Looks like we got unlucky */
+ CabStatus = CabinetFindFirst(SourceFileName, &Search);
+ }
}
else
{
@@ -315,10 +325,18 @@
DPRINT("Cannot open cabinet (%d)\n", CabStatus);
return STATUS_UNSUCCESSFUL;
}
- }
+
+ /* We have to start at the beginning here */
+ CabStatus = CabinetFindFirst(SourceFileName, &Search);
+ }
+
+ if (CabStatus != CAB_STATUS_SUCCESS)
+ {
+ DPRINT1("Unable to find '%S' in cabinet '%S'\n",
SourceFileName, CabinetGetCabinetName());
+ return STATUS_UNSUCCESSFUL;
+ }
CabinetSetDestinationPath(DestinationPathName);
- CabinetFindFirst( SourceFileName, &Search );
CabStatus = CabinetExtractFile(&Search);
if (CabStatus != CAB_STATUS_SUCCESS)
{