igir
Version:
🕹 A zero-setup ROM collection manager that sorts, filters, extracts or archives, patches, and reports on collections of any size on any OS.
27 lines (26 loc) • 930 B
JavaScript
import APSGBAPatch from "./apsGbaPatch.js";
import APSN64Patch from "./apsN64Patch.js";
import Patch from "./patch.js";
class APSPatch extends Patch {
static SUPPORTED_EXTENSIONS = [".aps"];
static FILE_SIGNATURE = Buffer.from("APS1");
/**
* Parse an .aps patch file and return either an {@link APSN64Patch} or {@link APSGBAPatch}
* depending on the patch's variant byte.
*/
static async patchFrom(file) {
return await file.extractToTempIOFile("r", async (patchFile) => {
patchFile.seek(this.FILE_SIGNATURE.length);
const byteFive = (await patchFile.readNext(1)).toString();
const byteSix = (await patchFile.readNext(1)).readUInt8();
if (byteFive === "0" && (byteSix === 0 || byteSix === 1)) {
return await APSN64Patch.patchFrom(file);
}
return await APSGBAPatch.patchFrom(file);
});
}
}
export {
APSPatch as default
};
//# sourceMappingURL=apsPatch.js.map