Browse Source

Fixed compilation errors in filesystem and added workaround for machines without PhysFS 2.0.

rude 16 years ago
parent
commit
5c75f3b5a5

+ 11 - 7
src/modules/filesystem/physfs/Filesystem.cpp

@@ -30,14 +30,17 @@ namespace filesystem
 namespace physfs
 namespace physfs
 {
 {
 	Filesystem::Filesystem()
 	Filesystem::Filesystem()
-		: open_count(0), buffer(0)
+		: open_count(0), buffer(0), isInited(false)
 	{
 	{
 	}
 	}
 
 
 	Filesystem::~Filesystem()
 	Filesystem::~Filesystem()
 	{
 	{
-		if(PHYSFS_isInit())
+		if(isInited)
+		{
+			isInited = false;
 			PHYSFS_deinit();
 			PHYSFS_deinit();
+		}
 	}
 	}
 
 
 	const char * Filesystem::getName() const
 	const char * Filesystem::getName() const
@@ -49,11 +52,12 @@ namespace physfs
 	{
 	{
 		if(!PHYSFS_init(arg0))
 		if(!PHYSFS_init(arg0))
 			throw Exception(PHYSFS_getLastError());
 			throw Exception(PHYSFS_getLastError());
+		isInited = true;
 	}
 	}
 
 
 	bool Filesystem::setIdentity( const char * ident )
 	bool Filesystem::setIdentity( const char * ident )
 	{
 	{
-		if(PHYSFS_isInit())
+		if(!isInited)
 			return false;
 			return false;
 
 
 		// Check whether save directory is already set.
 		// Check whether save directory is already set.
@@ -86,7 +90,7 @@ namespace physfs
 
 
 	bool Filesystem::setSource(const char * source)
 	bool Filesystem::setSource(const char * source)
 	{
 	{
-		if(!PHYSFS_isInit())
+		if(!isInited)
 			return false;
 			return false;
 
 
 		// Check whether directory is already set.
 		// Check whether directory is already set.
@@ -105,7 +109,7 @@ namespace physfs
 
 
 	bool Filesystem::setupWriteDirectory()
 	bool Filesystem::setupWriteDirectory()
 	{
 	{
-		if(!PHYSFS_isInit())
+		if(!isInited)
 			return false;
 			return false;
 
 
 		// These must all be set.
 		// These must all be set.
@@ -156,9 +160,9 @@ namespace physfs
 	const char * Filesystem::getWorkingDirectory()
 	const char * Filesystem::getWorkingDirectory()
 	{
 	{
 		#ifdef LOVE_WINDOWS
 		#ifdef LOVE_WINDOWS
-				_getcwd(cwdbuffer, _MAX_PATH);
+				_getcwd(cwdbuffer, LOVE_MAX_PATH);
 		#else
 		#else
-				char * temp = getcwd(cwdbuffer, LOVE_MAXPATHLEN);
+				char * temp = getcwd(cwdbuffer, LOVE_MAX_PATH);
 				if(temp == 0)
 				if(temp == 0)
 					return 0;
 					return 0;
 		#endif
 		#endif

+ 3 - 0
src/modules/filesystem/physfs/Filesystem.h

@@ -85,6 +85,9 @@ namespace physfs
 		// The full path to the source of the game.
 		// The full path to the source of the game.
 		std::string game_source;
 		std::string game_source;
 
 
+		// Workaround for machines without PhysFS 2.0
+		bool isInited;
+
 	protected:
 	protected:
 		
 		
 	public:
 	public: