UNPKG

dolphin-tool

Version:

🐬 dolphin-tool binaries and wrapper for Node.js.

71 lines 3.91 kB
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; import DolphinToolBin from './dolphinToolBin.js'; import { CompressionMethodWiaRvz, ContainerFormat } from './common.js'; import utils from './utils.js'; export default { convert(options) { return __awaiter(this, void 0, void 0, function* () { var _a, _b, _c; const blockSize = (_a = options.blockSize) !== null && _a !== void 0 ? _a : { // Unchangeable defaults of Dolphin v2412 [ContainerFormat.ISO]: undefined, [ContainerFormat.GCZ]: 32 * 1024, [ContainerFormat.WIA]: 2 * 1024 * 1024, [ContainerFormat.RVZ]: 128 * 1024, }[options.containerFormat]; const compressionMethod = (_b = options.compressionMethod) !== null && _b !== void 0 ? _b : { // Defaults of Dolphin v2412 [ContainerFormat.ISO]: undefined, [ContainerFormat.GCZ]: undefined, // deflate [ContainerFormat.WIA]: CompressionMethodWiaRvz.NONE, [ContainerFormat.RVZ]: CompressionMethodWiaRvz.ZSTD, }[options.containerFormat]; const compressionLevel = (_c = options.compressionLevel) !== null && _c !== void 0 ? _c : ( // Defaults of Dolphin v2412 compressionMethod !== undefined && compressionMethod !== CompressionMethodWiaRvz.NONE ? 5 : undefined); const runOptions = [ 'convert', '-i', options.inputFilename, '-o', options.outputFilename, '-f', options.containerFormat, ...(options.scrubJunk ? ['-s'] : []), ...(blockSize === undefined ? [] : ['-b', String(blockSize)]), ...(compressionMethod === undefined ? [] : ['-c', compressionMethod]), ...(compressionLevel === undefined ? [] : ['-l', String(compressionLevel)]), ]; if (process.platform === 'win32' && options.userFolderPath === undefined) { /** * Windows (and seemingly no other OS) has issues with concurrent or rapid execution of * `DolphinTool.exe`, resulting in popups with messages such as: * "IOS_FS: Failed to write new FST" * "IOS_FS: Failed to rename temporary FST file" * "File <userDir>/Wii/shared2/sys/SYSCONF could not be opened! This may happen with * improper permissions or use by another process." * To combat this, we have to use separate user directories per process. */ yield utils.wrapTempDir((temporaryDirectory) => __awaiter(this, void 0, void 0, function* () { return DolphinToolBin.run([ ...runOptions, '-u', temporaryDirectory, ], options); })); return; } yield DolphinToolBin.run([ ...runOptions, ...(options.userFolderPath ? ['-u', options.userFolderPath] : []), ], options); }); }, }; //# sourceMappingURL=dolphinToolConvert.js.map