I have a quite big object to serialize to disk, like this:
if (!EngineFile.empty())
{
std::ofstream OutEngineStream(EngineFile);
if (!OutEngineStream)
{
std::cerr << "Failed to write to file \"" << EngineFile << "\"! Aborting ..." << std::endl;
return -1;
}
engine->serialize(OutEngineStream);
OutEngineStream.close();
std::cout << "\"" << EngineFile << "\" successfully wrote to disk." << std::endl;
}
The problem is, somtimes serialize
requires larger disk space than available. e.g. there is only 30M storage available but serialize
requires 200M. In this case I can normally open
the stream. During serialize
everything goes well, and close
returns nothing. The program runs well, but there is only a 30M file on the disk.
How can I get to know about this case?