Check the data path before usage
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Wed, 8 Jun 2011 15:27:30 +0000 (17:27 +0200)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Wed, 20 Jul 2011 15:59:48 +0000 (17:59 +0200)
When not running in place, check if the assumed data path in
../share/APPNAME exists. If it doesn't exist, fall back to ../data
instead. This allows the program to run successfully from the checkout
directory even without the run-in-place flag active.

src/porting.cpp

index 7de042ab571143eb1e69b8d6fd958c60c094cd83..ff8cb3862276f3c1158b8336839dc7e9643221b7 100644 (file)
@@ -26,6 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "porting.h"
 #include "config.h"
 #include "debug.h"
+#include "filesys.h"
 
 #ifdef __APPLE__
        #include "CoreFoundation/CoreFoundation.h"
@@ -210,6 +211,11 @@ void initializePaths()
 
        path_data = std::string(buf) + "/../share/" + APPNAME;
        //path_data = std::string(INSTALL_PREFIX) + "/share/" + APPNAME;
+       if (!fs::PathExists(path_data)) {
+               dstream<<"WARNING: data path " << path_data << " not found!";
+               path_data = std::string(buf) + "/../data";
+               dstream<<" Trying " << path_data << std::endl;
+       }
        
        path_userdata = std::string(getenv("HOME")) + "/." + APPNAME;