Output: Verify output files are open after opening them.
This commit is contained in:
parent
0bd9bbae4c
commit
0a1613abe1
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue