All the code that writes XML to make the client_state.xml file was already
converted to iostreams. Only the "top-level" step, creating the file
(write_state_file), is still using a MFILE/MIOFILE. Then that MIOFILE is
wrapped in an ostream when passed to write_state().
write_state_file creates an MFILE because that way all the data is buffered
in memory first, and only written to disk when closed. But I don't see why
this is needed. It's writing to client_state_next.xml, closing, and then
renaming it to client_state.xml. I don't see any potential problem in
writing the _next file "incrementally" instead of first buffering it all.
I attach a proposed patch to make write_state_file use a std::ofstream.
I'd like some pre-commit reviewing...
The diff may be a bit hard to follow. It may be better to apply the patch
locally and review the resulting code instead of looking at the patch.
An ofstream is of course buffered, but that buffer will probably not fit the
entire client_state.xml file.
Synecdoche isn't using std::flush or std::endl anywhere, except when writing
to std::cerr.
I think the size of the buffer can be changed using the filebuf.