Output: Make OutputDirectory::create() be able to create binary files.
authorAli Saidi <saidi@eecs.umich.edu>
Thu, 2 Aug 2007 18:40:56 +0000 (14:40 -0400)
committerAli Saidi <saidi@eecs.umich.edu>
Thu, 2 Aug 2007 18:40:56 +0000 (14:40 -0400)
--HG--
extra : convert_revision : eae114ee5f27bb8b319df705d9b39bded185b8e8

src/base/output.cc
src/base/output.hh

index afcac03a5f2506cfd69734dc41cef5265c960e11..9d02a4a719a8b2b2c861a0d07af1c075852a9040 100644 (file)
@@ -87,7 +87,7 @@ OutputDirectory::resolve(const string &name)
 }
 
 ostream *
-OutputDirectory::create(const string &name)
+OutputDirectory::create(const string &name, bool binary)
 {
     if (name == "cerr" || name == "stderr")
         return &cerr;
@@ -95,7 +95,8 @@ OutputDirectory::create(const string &name)
     if (name == "cout" || name == "stdout")
         return &cout;
 
-    ofstream *file = new ofstream(resolve(name).c_str(), ios::trunc);
+    ofstream *file = new ofstream(resolve(name).c_str(),
+            ios::trunc | binary ?  ios::binary : (ios::openmode)0);
     if (!file->is_open())
         panic("Cannot open file %s", name);
 
index 0aae4ae81f0f6e6decf055762137d4bae4ba8eb6..5de0c4005f6999dbbd1969934b72494df615009f 100644 (file)
@@ -51,7 +51,7 @@ class OutputDirectory
     const std::string &directory();
 
     std::string resolve(const std::string &name);
-    std::ostream *create(const std::string &name);
+    std::ostream *create(const std::string &name, bool binary = false);
     std::ostream *find(const std::string &name);
 
     static bool isFile(const std::ostream *os);