mirror of
https://github.com/fmang/opustags.git
synced 2025-01-16 05:03:13 +01:00
check in before out
so as not to create empty files
This commit is contained in:
parent
1e138ad00d
commit
1021b4394d
42
opustags.c
42
opustags.c
@ -258,30 +258,10 @@ int main(int argc, char **argv){
|
||||
}
|
||||
}
|
||||
}
|
||||
FILE *out = NULL;
|
||||
if(path_out != NULL){
|
||||
if(strcmp(path_out, "-") == 0)
|
||||
out = stdout;
|
||||
else{
|
||||
if(!overwrite){
|
||||
if(access(path_out, F_OK) == 0){
|
||||
fprintf(stderr, "'%s' already exists (use -y to overwrite)\n", path_out);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
out = fopen(path_out, "w");
|
||||
if(!out){
|
||||
perror("fopen");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
FILE *in;
|
||||
if(strcmp(path_in, "-") == 0){
|
||||
if(set_all){
|
||||
fputs("can't open stdin for input when -S is specified\n", stderr);
|
||||
if(out)
|
||||
fclose(out);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
in = stdin;
|
||||
@ -290,10 +270,28 @@ int main(int argc, char **argv){
|
||||
in = fopen(path_in, "r");
|
||||
if(!in){
|
||||
perror("fopen");
|
||||
if(out)
|
||||
fclose(out);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
FILE *out = NULL;
|
||||
if(path_out != NULL){
|
||||
if(strcmp(path_out, "-") == 0)
|
||||
out = stdout;
|
||||
else{
|
||||
if(!overwrite){
|
||||
if(access(path_out, F_OK) == 0){
|
||||
fprintf(stderr, "'%s' already exists (use -y to overwrite)\n", path_out);
|
||||
fclose(in);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
out = fopen(path_out, "w");
|
||||
if(!out){
|
||||
perror("fopen");
|
||||
fclose(in);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
ogg_sync_state oy;
|
||||
ogg_stream_state os, enc;
|
||||
ogg_page og;
|
||||
|
Loading…
x
Reference in New Issue
Block a user