RupertAvery / PSXPackager

A utility to convert Playstation disc images in various formats to PBP format and back
Other
230 stars 15 forks source link

Some errors produce empty files and fail silently #49

Open joshbarrass opened 1 year ago

joshbarrass commented 1 year ago

In the case of some errors (an example of an error where this occurs is reported in #48), PSXPackager will write an empty (or almost empty) file and fail silently (exit code 0, which ordinarily indicates success). As a result, automated scripts cannot easily detect these failures and will assume that the output file is valid. For destructive scripts, i.e. scripts that delete the original files once conversion is complete, this will cause loss of data.

Ideally, the program should not return an exit code of 0 if the conversion was unsuccessful, and should also clean up after itself in such cases to prevent empty files from being misinterpreted as successful conversions.

Steps:

Expected results:

Conversion is unsuccessful. echo $? returns a non-zero value, indicating failure. No PBP file is produced.

Actual results:

Conversion is unsuccessful. echo $? returns 0, indicating success. A small PBP file containing no ROM data is produced.

RupertAvery commented 1 year ago

I will add an appropriate return value.

RupertAvery commented 1 year ago

So I found out that in linux the number returned is an unsigned int from 0-255, so the above gets returned as 0, 255, 254. I read that error values shoul be 0-125, as the MSB is used by the system. This is of course up to us, but what would you prefer or what is recommended or makes more sense?

Is 0, 1, 2 better?

joshbarrass commented 1 year ago

0, 1, 2 seems reasonable to me. I think these are pretty standard return codes to use.