diff --git a/src/chdman/chdmanCd.ts b/src/chdman/chdmanCd.ts index c007b25..3d9f1a9 100644 --- a/src/chdman/chdmanCd.ts +++ b/src/chdman/chdmanCd.ts @@ -2,6 +2,7 @@ import util from 'node:util'; import fs from 'node:fs'; import ChdmanBin from './chdmanBin.js'; import { CHDCompressionAlgorithm } from './common.js'; +import ChdmanInfo from './chdmanInfo.js'; export interface CreateCdOptions { outputFilename: string, @@ -47,6 +48,15 @@ export default { } throw error; } + + // Test the created file + try { + await ChdmanInfo.info({ + inputFilename: options.outputFilename, + }); + } catch (error) { + throw new Error(`created CHD is invalid: ${error}`); + } }, /** diff --git a/src/chdman/chdmanDvd.ts b/src/chdman/chdmanDvd.ts index 9feb70c..36a98e7 100644 --- a/src/chdman/chdmanDvd.ts +++ b/src/chdman/chdmanDvd.ts @@ -2,6 +2,7 @@ import util from 'node:util'; import fs from 'node:fs'; import ChdmanBin from './chdmanBin.js'; import { CHDCompressionAlgorithm } from './common.js'; +import ChdmanInfo from './chdmanInfo.js'; export interface CreateDvdOptions { outputFilename: string, @@ -45,6 +46,15 @@ export default { } throw error; } + + // Test the created file + try { + await ChdmanInfo.info({ + inputFilename: options.outputFilename, + }); + } catch (error) { + throw new Error(`created CHD is invalid: ${error}`); + } }, /** diff --git a/src/chdman/chdmanHd.ts b/src/chdman/chdmanHd.ts index f15a1a4..cb7dae5 100644 --- a/src/chdman/chdmanHd.ts +++ b/src/chdman/chdmanHd.ts @@ -2,6 +2,7 @@ import util from 'node:util'; import fs from 'node:fs'; import ChdmanBin from './chdmanBin.js'; import { CHDCompressionAlgorithm } from './common.js'; +import ChdmanInfo from './chdmanInfo.js'; export interface CreateHdOptions { outputFilename: string, @@ -68,6 +69,15 @@ export default { } throw error; } + + // Test the created file + try { + await ChdmanInfo.info({ + inputFilename: options.outputFilename, + }); + } catch (error) { + throw new Error(`created CHD is invalid: ${error}`); + } }, /** diff --git a/src/chdman/chdmanRaw.ts b/src/chdman/chdmanRaw.ts index c3a2fb2..2b48ed6 100644 --- a/src/chdman/chdmanRaw.ts +++ b/src/chdman/chdmanRaw.ts @@ -2,6 +2,7 @@ import util from 'node:util'; import fs from 'node:fs'; import { CHDCompressionAlgorithm } from './common.js'; import ChdmanBin from './chdmanBin.js'; +import ChdmanInfo from './chdmanInfo.js'; export interface CreateRawOptions { outputFilename: string, @@ -57,6 +58,15 @@ export default { } throw error; } + + // Test the created file + try { + await ChdmanInfo.info({ + inputFilename: options.outputFilename, + }); + } catch (error) { + throw new Error(`created CHD is invalid: ${error}`); + } }, async extractRaw(options: ExtractRawOptions): Promise {