[xiph-commits] r3785 - liboggz/trunk/src/tools

conrad at svn.annodex.net conrad at svn.annodex.net
Sat Nov 15 14:58:28 PST 2008


Author: conrad
Date: 2008-11-15 14:58:28 -0800 (Sat, 15 Nov 2008)
New Revision: 3785

Modified:
   liboggz/trunk/src/tools/oggz-merge.c
Log:
oggz-merge: allow use of stdin as in input ("-") so that the output of
an encoder can be piped in and merged with an existing file.


Modified: liboggz/trunk/src/tools/oggz-merge.c
===================================================================
--- liboggz/trunk/src/tools/oggz-merge.c	2008-11-15 22:47:17 UTC (rev 3784)
+++ liboggz/trunk/src/tools/oggz-merge.c	2008-11-15 22:58:28 UTC (rev 3785)
@@ -328,6 +328,7 @@
   char * progname;
   char * infilename = NULL, * outfilename = NULL;
   FILE * infile = NULL, * outfile = NULL;
+  int used_stdin = 0; /* Flag usage of stdin, only use it once */
   OMData * omdata;
   int i;
 
@@ -416,7 +417,15 @@
 
   while (optind < argc) {
     infilename = argv[optind++];
-    infile = fopen (infilename, "rb");
+    if (strcmp (infilename, "-") == 0) {
+      if (used_stdin) continue;
+
+      infile = stdin;
+      used_stdin = 1;
+    } else {
+      infile = fopen (infilename, "rb");
+    }
+
     if (infile == NULL) {
       fprintf (stderr, "%s: unable to open input file %s\n", progname,
 	       infilename);



More information about the commits mailing list