summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authororbea <orbea@fredslev.dk>2018-05-29 11:58:51 -0700
committerErik de Castro Lopo <erikd@mega-nerd.com>2018-06-11 09:57:09 +1000
commit5dff53c0cc3f8969b6a1d608ce6a4d120d78efce (patch)
treeca52feb84f042947297f85244ecf8ccb31531659
parent01eb19708c11f6aae1013e7c9c29c83efda33bfb (diff)
downloadflac-5dff53c0cc3f8969b6a1d608ce6a4d120d78efce.tar.gz
Fix --output-prefix with input-files in sub-directories
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>
-rw-r--r--src/flac/main.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/flac/main.c b/src/flac/main.c
index e36d8630..be072a3d 100644
--- a/src/flac/main.c
+++ b/src/flac/main.c
@@ -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)