diff --git a/package.json b/package.json index 607a8b4..c4f6532 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "patcher", "main": "dist/index.js", "scripts": { - "start": "rm -rf dist && tsc && node dist/index.js", + "start": "rm -rf dist && tsc", "test": "echo \"Error: no test specified\" && exit 1" }, "devDependencies": { diff --git a/src/ssn/extractFileStream.ts b/src/ssn/extractFileStream.ts index 43f9899..7e7dab9 100644 --- a/src/ssn/extractFileStream.ts +++ b/src/ssn/extractFileStream.ts @@ -11,18 +11,18 @@ import streamSetMaxLength from './streams/streamSetMaxLength'; * and must transparently span across multiple disks if necessary. */ export default function extractFileStream(file: ISsnFileEntry, inputStream: stream.Readable): stream.Readable { - const headerBuffer: Buffer = inputStream.read(30); - const localFileHeader = new DataView(headerBuffer.buffer); + const localFileHeader: Buffer = inputStream.read(30); //Local file header signature - if (localFileHeader.getUint32(0, true) !== 0x04034B50) { - throw new Error('Local file header had wrong magic'); + const magic = localFileHeader.readUInt32LE(0); + if (magic !== 0x04034B50) { + throw new Error(`Local file header had wrong magic; expected 0x04034B50 but got 0x${magic.toString(16).padStart(8, '0')}`); } //All fields in the local file header are copies of the central file header, so we can skip them. //FIXME: Maybe we should actually read these fields to verify that they are identical? //skip 22 bytes - const localFilenameSize = localFileHeader.getUint16(26, true); - const localExtraSize = localFileHeader.getUint16(28, true); + const localFilenameSize = localFileHeader.readUInt16LE(26); + const localExtraSize = localFileHeader.readUInt16LE(28); //skip local file name and extra field inputStream.read(localFilenameSize + localExtraSize);