Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
57 lines (51 sloc) 1.64 KB
struct {
char id[4];
uint32 fileNumber;
uint32 fileOffsetsOffset <format=hex>;
uint32 fileExtensionsOffset <format=hex>;
uint32 fileNamesOffset <format=hex>;
uint32 fileSizesOffset <format=hex>;
uint32 hashMapOffset <format=hex>;
} header;
FSeek(header.fileOffsetsOffset);
uint32 fileOffsets[header.fileNumber];
FSeek(header.fileExtensionsOffset);
struct {
char ext[4];
} fileExtensions[header.fileNumber];
FSeek(header.fileNamesOffset);
uint32 nameLength;
struct {
char name[nameLength];
} fileNames[header.fileNumber] <optimize=true>;
FSeek(header.fileSizesOffset);
uint32 fileSizes[header.fileNumber];
/*
Used to search for a given hash: find index of hash inside "hashes" list.
Skip to bucketOffsets[hash >> preHashShift] to start searching.
File is fileIndices[index];
*/
if(header.hashMapOffset) {
FSeek(header.hashMapOffset);
struct {
struct {
uint32 preHashShift;
uint32 bucketOffsetsOffset <format=hex>;
uint32 hashesOffset <format=hex>;
uint32 fileIndicesOffset <format=hex>;
} hashMapHeader;
FSeek(header.hashMapOffset + hashMapHeader.bucketOffsetsOffset);
short bucketOffsets[1<<(31-hashMapHeader.preHashShift)];
FSeek(header.hashMapOffset + hashMapHeader.hashesOffset);
uint32 hashes[header.fileNumber] <format=hex>;
FSeek(header.hashMapOffset + hashMapHeader.fileIndicesOffset);
uint16 fileIndices[header.fileNumber];
} hashMap;
}
local int i;
for (i = 0; i < header.fileNumber; i++) {
FSeek(fileOffsets[i]);
struct {
byte data[fileSizes[i]];
} file;
}
You can’t perform that action at this time.