bluecore/engine/FileSystem.h

58 lines
1.0 KiB
C
Raw Normal View History

2008-01-16 11:45:17 +00:00
#include "Utilities/Referenced.h"
class File : public Referenced
{
public:
bool isOpen ();
unsigned long read (char *buffer, unsigned long size);
};
class FileSystem : public Referenced
{
public:
FileSystem();
File *openBinary (const std::string& filename);
private:
static bool _PhysfsInialized;
};
FileSystem::FileSystem()
{
PHYSFS_init (0);
std::string appdir = PHYSFS_getUserDir();
appdir += ".bluecore";
if( !PHYSFS_setWriteDir(appdir.c_str()) )
{
if( (PHYSFS_setWriteDir(PHYSFS_getUserDir())) && (PHYSFS_mkdir(".bluecore")) )
PHYSFS_setWriteDir( appdir.c_str() );
}
PHYSFS_addToSearchPath( appdir.c_str(), 0 );
PHYSFS_addToSearchPath( "data", 1 );
char **rc = PHYSFS_enumerateFiles ( "" );
for ( char **i = rc; *i != 0; i++ )
{
std::string filename ( *i );
if ( filename.substr ( filename.size() - 4, 4 ) == ".zip" )
{
PHYSFS_addToSearchPath ( ( "data/" + filename ).c_str(), 1 );
BlueCore::log << ">>> Using addon: " << filename << endlog;
}
}
PHYSFS_freeList ( rc );
}