I would like to use PhysFS in conjunction with Boost.Serialization. I found an implementation here which uses Boost.Iostreams to create a PhysFS file stream. It works for basic operations, buy if I try ti use it with Boost.Serialization, I get the following error during runtime:
/usr/include/boost/iostreams/detail/optional.hpp:55: T& boost::iostreams::detail::optional<T>::operator*() [with T = boost::iostreams::detail::concept_adapter<PhysFS::FileDevice>]: Assertion `initialized_' failed.
Aborted
here is an example of the code.
PhysFS::init(argv[0]);
PhysFS::setWriteDir(".");
PhysFS::FileStream ofs("test.xml", PhysFS::OM_WRITE);
boost::archive::xml_oarchive xml(ofs);
vec2 vec(3.1415, 2.5);
xml << BOOST_SERIALIZATION_NVP(vec);
ofs.close();
PhysFS::deinit();
Is there any way to get a working file stream wrapper for PhysFS that will work with libraries like Boost.Serialization?
My mistake was calling ofs.close(), and also calling PhysFS::deinit before the destruction of ofs.