add the --output-prefix option
authorJosh Coalson <jcoalson@users.sourceforce.net>
Wed, 27 Jun 2001 06:53:54 +0000 (06:53 +0000)
committerJosh Coalson <jcoalson@users.sourceforce.net>
Wed, 27 Jun 2001 06:53:54 +0000 (06:53 +0000)
doc/documentation.html
man/flac.sgml
src/flac/main.c

index b23d76f..d405831 100644 (file)
                                <TT>-o filename</TT>
                        </TD>
                        <TD>
-                               Force the output file name (usually <TT><B>flac</B></TT> just changes the extension).
+                               Force the output file name (usually <TT><B>flac</B></TT> just changes the extension).  May only be used when encoding a single file.  May not be used in conjunction with <TT>--output-prefix</T>.
+                       </TD>
+               </TR>
+               <TR>
+                       <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
+                               <TT>--output-prefix string</TT>
+                       </TD>
+                       <TD>
+                               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 '<TT>/</TT>' slash.
                        </TD>
                </TR>
                <TR>
index a029389..d1c0282 100644 (file)
                <term><option>-o</option> <replaceable>filename</replaceable></term>
                <listitem>
                  <para>Force the output file name (usually flac just
-                   changes the extension).</para>
+                   changes the extension).  May only be used when
+                   encoding a single file.  May not be used in
+                   conjunction with --output-prefix.</para>
+               </listitem>
+             </varlistentry>
+
+             <varlistentry>
+               <term><option>--output-prefix</option> <replaceable>string</replaceable></term>
+               <listitem>
+                 <para>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).</para>
                </listitem>
              </varlistentry>
 
index f0b3a08..c071e3f 100644 (file)
@@ -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 {