Fix --output-prefix with input-files in sub-directories
authororbea <orbea@fredslev.dk>
Tue, 29 May 2018 18:58:51 +0000 (11:58 -0700)
committerErik de Castro Lopo <erikd@mega-nerd.com>
Sun, 10 Jun 2018 23:57:09 +0000 (09:57 +1000)
And make sure to reserve the whole file path when not using --output-prefix.

Fixes https://sourceforge.net/p/flac/bugs/463/
Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
src/flac/main.c

index e36d863..be072a3 100644 (file)
@@ -2173,12 +2173,30 @@ int decode_file(const char *infilename)
 const char *get_encoded_outfilename(const char *infilename)
 {
        const char *suffix = (option_values.use_ogg? ".oga" : ".flac");
-       return get_outfilename(infilename, suffix);
+       const char *p;
+
+       if(option_values.output_prefix) {
+               p = grabbag__file_get_basename(infilename);
+       }
+       else {
+               p = infilename;
+       }
+
+       return get_outfilename(p, suffix);
 }
 
 const char *get_decoded_outfilename(const char *infilename)
 {
        const char *suffix;
+       const char *p;
+
+       if(option_values.output_prefix) {
+               p = grabbag__file_get_basename(infilename);
+       }
+       else {
+               p = infilename;
+       }
+
        if(option_values.analyze) {
                suffix = ".ana";
        }
@@ -2197,7 +2215,7 @@ const char *get_decoded_outfilename(const char *infilename)
        else {
                suffix = ".wav";
        }
-       return get_outfilename(infilename, suffix);
+       return get_outfilename(p, suffix);
 }
 
 const char *get_outfilename(const char *infilename, const char *suffix)