diff options
Diffstat (limited to 'butl')
-rw-r--r-- | butl/filesystem.cxx | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/butl/filesystem.cxx b/butl/filesystem.cxx index 4aa2078..3249b58 100644 --- a/butl/filesystem.cxx +++ b/butl/filesystem.cxx @@ -248,7 +248,11 @@ namespace butl // Throws ios::failure on fdbuf read/write failures. // - ofs << ifs.rdbuf (); + // Note that the eos check is important: if the stream is at eos (empty + // file) then this write will fail. + // + if (ifs.peek () != ifdstream::traits_type::eof ()) + ofs << ifs.rdbuf (); ifs.close (); // Throws ios::failure on failure. ofs.close (); // Throws ios::failure on flush/close failure. |