*/
#include "usetup.h"
-#include <zlib.h>
#define NDEBUG
#include <debug.h>
IO_STATUS_BLOCK IoStatusBlock;
UNICODE_STRING FileName;
NTSTATUS NtStatus;
- ULONG Size;
RtlInitUnicodeString(&FileName, CabinetName);
return CAB_STATUS_INVALID_CAB;
}
- Size = 0;
Buffer = (PUCHAR)(PCABHeader + 1);
/* Read/skip any reserved bytes */
return CabinetFindNext(Search);
}
+/*
+ * 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:
ULONG
CabinetFindNext(PCAB_SEARCH Search)
{
- ULONG Status;
PCFFILE Prev;
ANSI_STRING AnsiString;
UNICODE_STRING UnicodeString;
// 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)
{
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);
ExtractHandler(Search->File, DestName);
}
- /* find the starting block of the file
- start with the first data block of the folder */
- CFData = (PCFDATA)(CabinetFolders[Search->File->FolderIndex].DataOffset + FileBuffer);
- CurrentOffset = 0;
+ if (Search->CFData)
+ CFData = Search->CFData;
+ else
+ CFData = (PCFDATA)(CabinetFolders[Search->File->FolderIndex].DataOffset + FileBuffer);
+
+ CurrentOffset = Search->Offset;
while (CurrentOffset + CFData->UncompSize <= Search->File->FileOffset)
{
/* walk the data blocks until we reach
CurrentOffset += CFData->UncompSize;
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 */