Make randtilegen report the file names it fails to open

Which of the two is erroring out can be inferred from the file name,
anyway.
This commit is contained in:
ISSOtm
2022-04-24 13:17:03 +02:00
committed by Eldred Habert
parent 3aabe9c799
commit 75b9d48990

View File

@@ -232,14 +232,14 @@ int main(int argc, char **argv) {
int len = sprintf(filename, "%s%" PRIu16 ".rng", argv[index], i); int len = sprintf(filename, "%s%" PRIu16 ".rng", argv[index], i);
rngRecorder = fopen(filename, "wb"); rngRecorder = fopen(filename, "wb");
if (!rngRecorder) { if (!rngRecorder) {
perror("RNG fopen"); perror(filename);
return 1; return 1;
} }
filename[len - 3] = 'p'; // `.rng` -> `.png` filename[len - 3] = 'p'; // `.rng` -> `.png`
FILE *img = fopen(filename, "wb"); FILE *img = fopen(filename, "wb");
if (!img) { if (!img) {
perror("PNG fopen"); perror(filename);
return 1; return 1;
} }
png_structp png = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); png_structp png = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);