summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAli Saidi <saidi@eecs.umich.edu>2007-08-02 14:40:56 -0400
committerAli Saidi <saidi@eecs.umich.edu>2007-08-02 14:40:56 -0400
commitc4e026daf4f22481d20c6f63d76ad23d5b65af45 (patch)
tree168793f30096688bfacba21a176e1baf427000ac
parentacb91c2dfa19dadc4549b2e0fced42b2a8bce34f (diff)
downloadgem5-c4e026daf4f22481d20c6f63d76ad23d5b65af45.tar.xz
Output: Make OutputDirectory::create() be able to create binary files.
--HG-- extra : convert_revision : eae114ee5f27bb8b319df705d9b39bded185b8e8
-rw-r--r--src/base/output.cc5
-rw-r--r--src/base/output.hh2
2 files changed, 4 insertions, 3 deletions
diff --git a/src/base/output.cc b/src/base/output.cc
index afcac03a5..9d02a4a71 100644
--- a/src/base/output.cc
+++ b/src/base/output.cc
@@ -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);
diff --git a/src/base/output.hh b/src/base/output.hh
index 0aae4ae81..5de0c4005 100644
--- a/src/base/output.hh
+++ b/src/base/output.hh
@@ -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);