From cd22af6cc42687b7b80e03955317ebc0c6aeed2c Mon Sep 17 00:00:00 2001 From: Josh Coalson Date: Wed, 27 Jun 2001 06:53:54 +0000 Subject: [PATCH] add the --output-prefix option --- doc/documentation.html | 10 +++++++++- man/flac.sgml | 15 ++++++++++++++- src/flac/main.c | 16 +++++++++++++--- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/doc/documentation.html b/doc/documentation.html index b23d76f..d405831 100644 --- a/doc/documentation.html +++ b/doc/documentation.html @@ -305,7 +305,15 @@ -o filename - Force the output file name (usually flac just changes the extension). + Force the output file name (usually flac just changes the extension). May only be used when encoding a single file. May not be used in conjunction with --output-prefix. + + + + + --output-prefix string + + + Prefix each output file name with the given string. This can be useful for encoding/decoding files to a different directory. Make sure if your string is a path name that it ends with a trailing '/' slash. diff --git a/man/flac.sgml b/man/flac.sgml index a029389..d1c0282 100644 --- a/man/flac.sgml +++ b/man/flac.sgml @@ -112,7 +112,20 @@ filename Force the output file name (usually flac just - changes the extension). + changes the extension). May only be used when + encoding a single file. May not be used in + conjunction with --output-prefix. + + + + + string + + Prefix each output file name with the given + string. This can be useful for encoding/decoding + files to a different directory. Make sure if your + string is a path name that it ends with a trailing + `/' (slash). diff --git a/src/flac/main.c b/src/flac/main.c index f0b3a08..c071e3f 100644 --- a/src/flac/main.c +++ b/src/flac/main.c @@ -38,7 +38,7 @@ static int decode_file(const char *infilename, const char *forced_outfilename); FLAC__bool verify = false, verbose = true, lax = false, test_only = false, analyze = false; FLAC__bool do_mid_side = true, loose_mid_side = false, do_exhaustive_model_search = false, do_qlp_coeff_prec_search = false; FLAC__bool force_to_stdout = false, delete_input = false, sector_align = false; -const char *cmdline_forced_outfilename = 0; +const char *cmdline_forced_outfilename = 0, *output_prefix = 0; analysis_options aopts = { false, false }; unsigned padding = 0; unsigned max_lpc_order = 8; @@ -96,6 +96,8 @@ int main(int argc, char *argv[]) delete_input = true; else if(0 == strcmp(argv[i], "--delete-input-file-")) delete_input = false; + else if(0 == strcmp(argv[i], "--output-prefix")) + output_prefix = argv[++i]; else if(0 == strcmp(argv[i], "--sector-align")) sector_align = true; else if(0 == strcmp(argv[i], "--sector-align-")) @@ -339,6 +341,12 @@ int main(int argc, char *argv[]) else if(format_sample_rate >= 0 && format_sample_rate != 2) return usage("ERROR: --sector-align can only be done with sample rate of 44100\n"); } + if(argc - i > 1 && cmdline_forced_outfilename) { + return usage("ERROR: -o cannot be used with multiple files\n"); + } + if(cmdline_forced_outfilename && output_prefix) { + return usage("ERROR: --output-prefix conflicts with -o\n"); + } if(verbose) { fprintf(stderr, "\n"); @@ -586,7 +594,8 @@ int encode_file(const char *infilename, const char *forced_outfilename, FLAC__bo if(encode_infile == stdin || force_to_stdout) strcpy(outfilename, "-"); else { - strcpy(outfilename, infilename); + strcpy(outfilename, output_prefix? output_prefix : ""); + strcat(outfilename, infilename); if(0 == (p = strrchr(outfilename, '.'))) strcat(outfilename, ".flac"); else { @@ -637,7 +646,8 @@ int decode_file(const char *infilename, const char *forced_outfilename) strcpy(outfilename, "-"); else { const char *suffix = suffixes[analyze? 2 : format_is_wave? 0 : 1]; - strcpy(outfilename, infilename); + strcpy(outfilename, output_prefix? output_prefix : ""); + strcat(outfilename, infilename); if(0 == (p = strrchr(outfilename, '.'))) strcat(outfilename, suffix); else { -- 2.7.4