|
|
|
|
|
|
|
|
|
|
|
import { UINT16_LE, UINT32_LE } from "token-types"; |
|
|
export const Signature = { |
|
|
LocalFileHeader: 0x04034b50, |
|
|
DataDescriptor: 0x08074b50, |
|
|
CentralFileHeader: 0x02014b50, |
|
|
EndOfCentralDirectory: 0x06054b50 |
|
|
}; |
|
|
export const DataDescriptor = { |
|
|
get(array) { |
|
|
const flags = UINT16_LE.get(array, 6); |
|
|
return { |
|
|
signature: UINT32_LE.get(array, 0), |
|
|
compressedSize: UINT32_LE.get(array, 8), |
|
|
uncompressedSize: UINT32_LE.get(array, 12), |
|
|
}; |
|
|
}, len: 16 |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const LocalFileHeaderToken = { |
|
|
get(array) { |
|
|
const flags = UINT16_LE.get(array, 6); |
|
|
return { |
|
|
signature: UINT32_LE.get(array, 0), |
|
|
minVersion: UINT16_LE.get(array, 4), |
|
|
dataDescriptor: !!(flags & 0x0008), |
|
|
compressedMethod: UINT16_LE.get(array, 8), |
|
|
compressedSize: UINT32_LE.get(array, 18), |
|
|
uncompressedSize: UINT32_LE.get(array, 22), |
|
|
filenameLength: UINT16_LE.get(array, 26), |
|
|
extraFieldLength: UINT16_LE.get(array, 28), |
|
|
filename: null |
|
|
}; |
|
|
}, len: 30 |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const EndOfCentralDirectoryRecordToken = { |
|
|
get(array) { |
|
|
return { |
|
|
signature: UINT32_LE.get(array, 0), |
|
|
nrOfThisDisk: UINT16_LE.get(array, 4), |
|
|
nrOfThisDiskWithTheStart: UINT16_LE.get(array, 6), |
|
|
nrOfEntriesOnThisDisk: UINT16_LE.get(array, 8), |
|
|
nrOfEntriesOfSize: UINT16_LE.get(array, 10), |
|
|
sizeOfCd: UINT32_LE.get(array, 12), |
|
|
offsetOfStartOfCd: UINT32_LE.get(array, 16), |
|
|
zipFileCommentLength: UINT16_LE.get(array, 20), |
|
|
}; |
|
|
}, len: 22 |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const FileHeader = { |
|
|
get(array) { |
|
|
const flags = UINT16_LE.get(array, 8); |
|
|
return { |
|
|
signature: UINT32_LE.get(array, 0), |
|
|
minVersion: UINT16_LE.get(array, 6), |
|
|
dataDescriptor: !!(flags & 0x0008), |
|
|
compressedMethod: UINT16_LE.get(array, 10), |
|
|
compressedSize: UINT32_LE.get(array, 20), |
|
|
uncompressedSize: UINT32_LE.get(array, 24), |
|
|
filenameLength: UINT16_LE.get(array, 28), |
|
|
extraFieldLength: UINT16_LE.get(array, 30), |
|
|
fileCommentLength: UINT16_LE.get(array, 32), |
|
|
relativeOffsetOfLocalHeader: UINT32_LE.get(array, 42), |
|
|
filename: null |
|
|
}; |
|
|
}, len: 46 |
|
|
}; |
|
|
|