summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/base/stats/text.cc8
-rw-r--r--src/sim/serialize.cc2
2 files changed, 7 insertions, 3 deletions
diff --git a/src/base/stats/text.cc b/src/base/stats/text.cc
index 6f40d92c8..f65b77777 100644
--- a/src/base/stats/text.cc
+++ b/src/base/stats/text.cc
@@ -107,7 +107,8 @@ Text::open(std::ostream &_stream)
mystream = false;
stream = &_stream;
- assert(valid());
+ if (!valid())
+ fatal("Unable to open output stream for writing\n");
}
void
@@ -118,13 +119,14 @@ Text::open(const std::string &file)
mystream = true;
stream = new ofstream(file.c_str(), ios::trunc);
- assert(valid());
+ if (!valid())
+ fatal("Unable to open statistics file for writing\n");
}
bool
Text::valid() const
{
- return stream != NULL;
+ return stream != NULL && stream->good();
}
void
diff --git a/src/sim/serialize.cc b/src/sim/serialize.cc
index 7050779b2..a4851d3f6 100644
--- a/src/sim/serialize.cc
+++ b/src/sim/serialize.cc
@@ -405,6 +405,8 @@ Serializable::serializeAll(const std::string &cpt_dir)
string cpt_file = dir + Checkpoint::baseFilename;
ofstream outstream(cpt_file.c_str());
time_t t = time(NULL);
+ if (!outstream.is_open())
+ fatal("Unable to open file %s for writing\n", cpt_file.c_str());
outstream << "// checkpoint generated: " << ctime(&t);
globals.serialize(outstream);