]> git.donarmstrong.com Git - bamtools.git/blobdiff - src/api/internal/io/BamPipe_p.cpp
Changed platform check to use standard cmake variable (issue #66)
[bamtools.git] / src / api / internal / io / BamPipe_p.cpp
index d70018955fe45e66c4894874af7a22e1105f563e..6af4af146410df491b01ee8f74937369fa12f27c 100644 (file)
@@ -2,7 +2,7 @@
 // BamPipe_p.cpp (c) 2011 Derek Barnett
 // Marth Lab, Department of Biology, Boston College
 // ---------------------------------------------------------------------------
-// Last modified: 25 October 2011 (DB)
+// Last modified: 18 October 2012 (DB)
 // ---------------------------------------------------------------------------
 // Provides BAM pipe-specific IO behavior
 // ***************************************************************************
@@ -29,13 +29,21 @@ bool BamPipe::Open(const IBamIODevice::OpenMode mode) {
     Close();
 
     // open stdin/stdout depending on requested openmode
+#if defined( SYSTEM_NODEJS ) && SYSTEM_NODEJS == 1
+    if ( mode == IBamIODevice::ReadOnly )
+        m_stream = stdin;
+    else if ( mode == IBamIODevice::WriteOnly )
+        m_stream = stdout;
+#else
     if ( mode == IBamIODevice::ReadOnly )
         m_stream = freopen(0, "rb", stdin);
     else if ( mode == IBamIODevice::WriteOnly )
         m_stream = freopen(0, "wb", stdout);
+#endif // SYSTEM_NODEJS
+
     else {
-        const string errorType = string( mode == IBamIODevice::ReadWrite ? "unsupported"
-                                                                         : "unknown" );
+        const string errorType = string( (mode == IBamIODevice::ReadWrite) ? "unsupported"
+                                                                           : "unknown" );
         const string message = errorType + " open mode requested";
         SetErrorString("BamPipe::Open", message);
         return false;