Skip to content

Commit c453a18

Browse files
author
twojstaryzdomu
committed
Fail if output file already exists
1 parent a809238 commit c453a18

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

bchunk.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,12 @@ int writetrack(FILE *bf, struct track_t *track)
329329
int16_t i;
330330
float fl;
331331

332-
if (!(f = fopen(track->output, "wb")))
333-
die_format(4, " Could not fopen track file: %s\n", strerror(errno));
332+
if (!(f = fopen(track->output, "wbx"))) {
333+
if (errno == EEXIST)
334+
die_format(2, "%2d: output file %s already exists, aborting\n", track->num, track->output);
335+
else
336+
die_format(4, " Could not fopen track file: %s\n", strerror(errno));
337+
}
334338

335339
printf("%2d: %s ", track->num, track->output);
336340

0 commit comments

Comments
 (0)