retroload
Version:
Command line utility for converting tape archive files of historical computers into sound for loading them on real devices
25 lines • 782 B
JavaScript
import fs from 'fs';
// eslint-disable-next-line consistent-return
export function readFile(path) {
try {
const buffer = fs.readFileSync(path);
const arrayBuffer = buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
return new Uint8Array(arrayBuffer, 0, buffer.byteLength);
}
catch (_a) {
// eslint-disable-next-line no-console
console.error(`Error: Unable to read ${path}.`);
process.exit(1);
}
}
export function writeFile(path, data) {
try {
fs.writeFileSync(path, data);
}
catch (_a) {
// eslint-disable-next-line no-console
console.error(`Error: Unable to write output file ${path}`);
process.exit(1);
}
}
//# sourceMappingURL=Utils.js.map