]> git.donarmstrong.com Git - bamtools.git/commitdiff
Added support for "-" as indicator for stdin/stdout
authorderek <derekwbarnett@gmail.com>
Fri, 2 Sep 2011 17:01:43 +0000 (13:01 -0400)
committerderek <derekwbarnett@gmail.com>
Fri, 2 Sep 2011 17:01:43 +0000 (13:01 -0400)
* Thanks to Aaron Quinlan for suggestion

src/api/internal/BgzfStream_p.cpp

index aba2a0786a095db16c6adf6c8830a3f14bd37f4a..ae645fd35d6164ac9d43399f5463c9bf1a830c96 100644 (file)
@@ -3,7 +3,7 @@
 // Marth Lab, Department of Biology, Boston College
 // All rights reserved.
 // ---------------------------------------------------------------------------
 // Marth Lab, Department of Biology, Boston College
 // All rights reserved.
 // ---------------------------------------------------------------------------
-// Last modified: 5 April 2011(DB)
+// Last modified: 2 September 2011(DB)
 // ---------------------------------------------------------------------------
 // Based on BGZF routines developed at the Broad Institute.
 // Provides the basic functionality for reading & writing BGZF files
 // ---------------------------------------------------------------------------
 // Based on BGZF routines developed at the Broad Institute.
 // Provides the basic functionality for reading & writing BGZF files
@@ -253,15 +253,15 @@ bool BgzfStream::Open(const string& filename, const char* mode) {
     }
 
     // open BGZF stream on a file
     }
 
     // open BGZF stream on a file
-    if ( (filename != "stdin") && (filename != "stdout") )
+    if ( (filename != "stdin") && (filename != "stdout") && (filename != "-"))
         Stream = fopen(filename.c_str(), mode);
 
     // open BGZF stream on stdin
         Stream = fopen(filename.c_str(), mode);
 
     // open BGZF stream on stdin
-    else if ( (filename == "stdin") && (strcmp(mode, "rb") == 0 ) )
+    else if ( (filename == "stdin" || filename == "-") && (strcmp(mode, "rb") == 0 ) )
         Stream = freopen(NULL, mode, stdin);
 
     // open BGZF stream on stdout
         Stream = freopen(NULL, mode, stdin);
 
     // open BGZF stream on stdout
-    else if ( (filename == "stdout") && (strcmp(mode, "wb") == 0) )
+    else if ( (filename == "stdout" || filename == "-") && (strcmp(mode, "wb") == 0) )
         Stream = freopen(NULL, mode, stdout);
 
     if ( !Stream ) {
         Stream = freopen(NULL, mode, stdout);
 
     if ( !Stream ) {