Simplify CLI -r option

This commit is contained in:
bnnm 2018-09-07 19:48:03 +02:00
parent c9ca0e4394
commit 311f4c1689

View File

@ -44,7 +44,6 @@ static void usage(const char * name) {
" -s N: select subsong N, if the format supports multiple subsongs\n" " -s N: select subsong N, if the format supports multiple subsongs\n"
" -m: print metadata only, don't decode\n" " -m: print metadata only, don't decode\n"
" -L: append a smpl chunk and create a looping wav\n" " -L: append a smpl chunk and create a looping wav\n"
" -r outfile2.wav: output a second time after resetting (for testing)\n"
" -2 N: only output the Nth (first is 0) set of stereo channels\n" " -2 N: only output the Nth (first is 0) set of stereo channels\n"
" -p: output to stdout (for piping into another program)\n" " -p: output to stdout (for piping into another program)\n"
" -P: output to stdout even if stdout is a terminal\n" " -P: output to stdout even if stdout is a terminal\n"
@ -52,6 +51,7 @@ static void usage(const char * name) {
" -x: decode and print adxencd command line to encode as ADX\n" " -x: decode and print adxencd command line to encode as ADX\n"
" -g: decode and print oggenc command line to encode as OGG\n" " -g: decode and print oggenc command line to encode as OGG\n"
" -b: decode and print batch variable commands\n" " -b: decode and print batch variable commands\n"
" -r: output a second file after resetting (for testing)\n"
, name); , name);
} }
@ -59,7 +59,6 @@ static void usage(const char * name) {
typedef struct { typedef struct {
char * infilename; char * infilename;
char * outfilename; char * outfilename;
char * outfilename_reset;
int ignore_loop; int ignore_loop;
int force_loop; int force_loop;
int really_force_loop; int really_force_loop;
@ -70,6 +69,7 @@ typedef struct {
int print_adxencd; int print_adxencd;
int print_oggenc; int print_oggenc;
int print_batchvar; int print_batchvar;
int test_reset;
int write_lwav; int write_lwav;
int only_stereo; int only_stereo;
int stream_index; int stream_index;
@ -96,7 +96,7 @@ static int parse_config(cli_config *cfg, int argc, char ** argv) {
opterr = 0; opterr = 0;
/* read config */ /* read config */
while ((opt = getopt(argc, argv, "o:l:f:d:ipPcmxeLEFr:gb2:s:")) != -1) { while ((opt = getopt(argc, argv, "o:l:f:d:ipPcmxeLEFrgb2:s:")) != -1) {
switch (opt) { switch (opt) {
case 'o': case 'o':
cfg->outfilename = optarg; cfg->outfilename = optarg;
@ -145,7 +145,7 @@ static int parse_config(cli_config *cfg, int argc, char ** argv) {
cfg->write_lwav = 1; cfg->write_lwav = 1;
break; break;
case 'r': case 'r':
cfg->outfilename_reset = optarg; cfg->test_reset = 1;
break; break;
case '2': case '2':
cfg->only_stereo = atoi(optarg); cfg->only_stereo = atoi(optarg);
@ -475,10 +475,14 @@ int main(int argc, char ** argv) {
/* try again with (for testing reset_vgmstream, simulates a seek to 0) */ /* try again with (for testing reset_vgmstream, simulates a seek to 0) */
if (cfg.outfilename_reset) { if (cfg.test_reset) {
outfile = fopen(cfg.outfilename_reset,"wb"); char outfilename_temp[PATH_LIMIT];
strcpy(outfilename_temp, cfg.outfilename);
strcat(outfilename_temp, ".reset.wav");
outfile = fopen(outfilename_temp,"wb");
if (!outfile) { if (!outfile) {
fprintf(stderr,"failed to open %s for output\n",cfg.outfilename_reset); fprintf(stderr,"failed to open %s for output\n",outfilename_temp);
goto fail; goto fail;
} }