fix crash when failing to save file.

https://gna.org/bugs/index.php?23301
This commit is contained in:
gfgtdf 2015-02-25 17:05:59 +01:00
parent f2e4d3c875
commit d12c594d90

View File

@ -786,8 +786,15 @@ std::ostream *ostream_file(std::string const &fname)
{
LOG_FS << "streaming " << fname << " for writing.\n";
#if 1
boost::iostreams::file_descriptor_sink fd(iostream_path(fname), std::ios_base::binary);
return new boost::iostreams::stream<boost::iostreams::file_descriptor_sink>(fd, 4096, 0);
try
{
boost::iostreams::file_descriptor_sink fd(iostream_path(fname), std::ios_base::binary);
return new boost::iostreams::stream<boost::iostreams::file_descriptor_sink>(fd, 4096, 0);
}
catch(BOOST_IOSTREAMS_FAILURE& e)
{
throw filesystem::io_exception(e.what());
}
#else
return new bfs::ofstream(path(fname), std::ios_base::binary);
#endif