From 5c75f3b5a57cdc9db907caa9e4cadf19e55fe487 Mon Sep 17 00:00:00 2001 From: rude Date: Thu, 13 Aug 2009 21:55:05 +0200 Subject: [PATCH] Fixed compilation errors in filesystem and added workaround for machines without PhysFS 2.0. --- src/modules/filesystem/physfs/Filesystem.cpp | 18 +++++++++++------- src/modules/filesystem/physfs/Filesystem.h | 3 +++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/modules/filesystem/physfs/Filesystem.cpp b/src/modules/filesystem/physfs/Filesystem.cpp index 377ef0bfb..dfa5a72df 100644 --- a/src/modules/filesystem/physfs/Filesystem.cpp +++ b/src/modules/filesystem/physfs/Filesystem.cpp @@ -30,14 +30,17 @@ namespace filesystem namespace physfs { Filesystem::Filesystem() - : open_count(0), buffer(0) + : open_count(0), buffer(0), isInited(false) { } Filesystem::~Filesystem() { - if(PHYSFS_isInit()) + if(isInited) + { + isInited = false; PHYSFS_deinit(); + } } const char * Filesystem::getName() const @@ -49,11 +52,12 @@ namespace physfs { if(!PHYSFS_init(arg0)) throw Exception(PHYSFS_getLastError()); + isInited = true; } bool Filesystem::setIdentity( const char * ident ) { - if(PHYSFS_isInit()) + if(!isInited) return false; // Check whether save directory is already set. @@ -86,7 +90,7 @@ namespace physfs bool Filesystem::setSource(const char * source) { - if(!PHYSFS_isInit()) + if(!isInited) return false; // Check whether directory is already set. @@ -105,7 +109,7 @@ namespace physfs bool Filesystem::setupWriteDirectory() { - if(!PHYSFS_isInit()) + if(!isInited) return false; // These must all be set. @@ -156,9 +160,9 @@ namespace physfs const char * Filesystem::getWorkingDirectory() { #ifdef LOVE_WINDOWS - _getcwd(cwdbuffer, _MAX_PATH); + _getcwd(cwdbuffer, LOVE_MAX_PATH); #else - char * temp = getcwd(cwdbuffer, LOVE_MAXPATHLEN); + char * temp = getcwd(cwdbuffer, LOVE_MAX_PATH); if(temp == 0) return 0; #endif diff --git a/src/modules/filesystem/physfs/Filesystem.h b/src/modules/filesystem/physfs/Filesystem.h index 9e06d976e..83e977ac1 100644 --- a/src/modules/filesystem/physfs/Filesystem.h +++ b/src/modules/filesystem/physfs/Filesystem.h @@ -85,6 +85,9 @@ namespace physfs // The full path to the source of the game. std::string game_source; + // Workaround for machines without PhysFS 2.0 + bool isInited; + protected: public: