- Cache the last data block and offset so we don't have to search from the start each time
- This avoids needless swapping of cabinet data in and out of RAM
- File copy in text-mode setup on 32 MB RAM is down from 8 minutes to 20 seconds (in my testing)

svn path=/trunk/; revision=54632
This commit is contained in:
Cameron Gutman 2011-12-10 04:20:39 +00:00
parent 80e8caa0b9
commit 13adb6230a
2 changed files with 17 additions and 4 deletions

View file

@ -757,6 +757,12 @@ CabinetFindNext(PCAB_SEARCH Search)
// FIXME: check for match against search criteria
if (Search->File != Prev)
{
if (Prev == NULL || Search->File->FolderIndex != Prev->FolderIndex)
{
Search->CFData = NULL;
Search->Offset = 0;
}
/* don't match the file we started with */
if (wcscmp(Search->Search, L"*") == 0)
{
@ -1011,10 +1017,12 @@ CabinetExtractFile(PCAB_SEARCH Search)
ExtractHandler(Search->File, DestName);
}
/* find the starting block of the file
start with the first data block of the folder */
if (Search->CFData)
CFData = Search->CFData;
else
CFData = (PCFDATA)(CabinetFolders[Search->File->FolderIndex].DataOffset + FileBuffer);
CurrentOffset = 0;
CurrentOffset = Search->Offset;
while (CurrentOffset + CFData->UncompSize <= Search->File->FileOffset)
{
/* walk the data blocks until we reach
@ -1023,6 +1031,9 @@ CabinetExtractFile(PCAB_SEARCH Search)
CFData = (PCFDATA)((char *)(CFData + 1) + DataReserved + CFData->CompSize);
}
Search->CFData = CFData;
Search->Offset = CurrentOffset;
/* now decompress and discard any data in
the block before the start of the file */

View file

@ -108,6 +108,8 @@ typedef struct _CAB_SEARCH
WCHAR Cabinet[MAX_PATH];
USHORT Index;
PCFFILE File; // Pointer to current CFFILE
PCFDATA CFData;
ULONG Offset;
} CAB_SEARCH, *PCAB_SEARCH;