Skip to content

Commit

Permalink
Set output files explicitly using -o switch
Browse files Browse the repository at this point in the history
If files order is wrong or output file is not specified abbinder
will rewrite first file in the input file list. In order to avoid
this: require setting output file explicitly

fixes #13
  • Loading branch information
gonzoua committed Nov 15, 2013
1 parent c9ca19f commit 35b49c3
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions abbinder.m
Expand Up @@ -47,7 +47,7 @@
void usage(char *cmd)
{
printf("Usage: %s [-Aehqsv] [-c 1|2] [-r samplerate] [-a author] [-t title] [-i filelist] "
"outfile [@chapter_1@ infile @chapter_2@ ...]\n", cmd);
"-o outfile [@chapter_1@ infile @chapter_2@ ...]\n", cmd);
printf("\t-a author\tset book author\n");
printf("\t-A\t\tadd audiobook to iTunes\n");
printf("\t-b bitrate\tset bitrate (KBps)\n");
Expand All @@ -62,6 +62,7 @@ void usage(char *cmd)
printf("\t-h\t\tshow this message\n");
printf("\t-i file\t\tget input files list from file, \"-\" for standard input\n");
printf("\t-l hours\t\tsplit audiobook to volumes max # hours long\n");
printf("\t-o outfile\t\taudiobook output file\n");
printf("\t-q\t\tquiet mode (no output)\n");
printf("\t-r rate\t\tsample rate of audiobook. Default: 44100\n");
printf("\t-s\t\tskip errors and go on with conversion\n");
Expand Down Expand Up @@ -123,7 +124,7 @@ int main (int argc, char * argv[]) {
NSMutableArray *volumeChapters = [[NSMutableArray alloc] init];

NSZombieEnabled = YES;
while ((c = getopt(argc, argv, "a:Ab:c:C:eE:g:hi:l:qr:st:v")) != -1) {
while ((c = getopt(argc, argv, "a:Ab:c:C:eE:g:hi:l:o:qr:st:v")) != -1) {
switch (c) {
case 'h':
usage(argv[0]);
Expand Down Expand Up @@ -189,19 +190,17 @@ int main (int argc, char * argv[]) {
case 'l':
maxVolumeDuration = atoi(optarg)*3600; // convert to seconds
break;
case 'o':
outFile = [NSString stringWithUTF8String:optarg];
break;
default:
usage(argv[0]);
exit(1);
}
}

// Do we have output file et al?
if (optind < argc)
{
outFile = [NSString stringWithUTF8String:argv[optind]];
optind++;
}
else
if (outFile == nil)
{
fprintf(stderr, "No output file specified\n");
usage(argv[0]);
Expand Down

0 comments on commit 35b49c3

Please sign in to comment.