I have a problem. I have lots of code that uses ifstreams in this manner:
ex:
bool AudioManager::_loadSounds( const std::string& path, const std::string& appendPath )
{
//open the file
std::ifstream ifs( path.c_str() );
//ensure it is open
if(!ifs.is_open())
{
return false;
}
std::string line;
//read each sound
while( getline( ifs, line ) )
{
...
The problem is I need to make an application-wide change to use PhysFS. All data will stay structured the same directory wise except it will be compartmentalized into zip files.
Is there a simple way to make PhysFS apply to ifstreams so that I do not need to modify all these classes?
There is not a simple way to do it. No matter what, you're going to have to not use fstreams. However, you can continue to use streams by simply writing a std::streambuf
-derived class that pulls its data from PhysFS. This isn't a trivial thing, since streambuf
has various bits of complexity to it. But it is certainly doable.
You can take any istream
-derived class and shove a different streambuf
into it.