|
47 | 47 | "\tGodmar Back < [email protected]>, Colas Nahaboo < [email protected]>\n" \ |
48 | 48 | "\tMatthew Green < [email protected]> & twojstaryzdomu <@github.com>.\n" \ |
49 | 49 | "\tReleased under the GNU GPL, version 2 or later (at your option).\n\n" |
| 50 | + |
| 51 | +#define HINT "\nUse '-t' to include track # in output filename. " \ |
| 52 | + "Remaining tracks were not processed\n" |
50 | 53 |
|
51 | 54 | #define CUELLEN 1024 |
52 | 55 | #define SECTLEN 2352 |
@@ -332,10 +335,15 @@ int writetrack(FILE *bf, struct track_t *track) |
332 | 335 | int16_t i; |
333 | 336 | float fl; |
334 | 337 |
|
335 | | - printf("%2d: %s ", track->num, track->output); |
| 338 | + if (!(f = fopen(track->output, "wbx"))) { |
| 339 | + if (errno == EEXIST) |
| 340 | + die_format(5, "%2d: skipped: output file %s already exists, aborting\n%s", |
| 341 | + track->num, track->output, HINT); |
| 342 | + else |
| 343 | + die_format(4, " Could not fopen track file: %s\n", strerror(errno)); |
| 344 | + } |
336 | 345 |
|
337 | | - if (!(f = fopen(track->output, "wb"))) |
338 | | - die_format(4, " Could not fopen track file: %s\n", strerror(errno)); |
| 346 | + printf("%2d: %s ", track->num, track->output); |
339 | 347 |
|
340 | 348 | if (fseek(bf, track->start, SEEK_SET)) |
341 | 349 | die_format(4, " Could not fseek to track location: %s\n", strerror(errno)); |
@@ -463,6 +471,9 @@ int set_output(struct track_t *track, char *binfile, char *basefile, int trackad |
463 | 471 | die(4, "set_output(): asprintf() failed, out of memory\n"); |
464 | 472 | free(bname); |
465 | 473 | bname = NULL; |
| 474 | + if (strcmp(track->output, track->file) == 0) |
| 475 | + die_format(5, "%2d: skipped: output file %s same as input file, aborting\n%s", |
| 476 | + track->num, track->output, HINT); |
466 | 477 | return 1; |
467 | 478 | } |
468 | 479 |
|
|
0 commit comments