+ else
+ {
+ // allow symbolic links
+ PHYSFS_permitSymbolicLinks(1);
+
+ find_userdir();
+ find_datadir();
+ }
+ }
+
+ void find_datadir()
+ {
+ // check if we run from source dir
+ char* basepath_c = SDL_GetBasePath();
+ std::string basepath = basepath_c;
+ SDL_free(basepath_c);
+
+ std::string datadir = FileSystem::join(basepath, "data");
+ std::string testfname = FileSystem::join(datadir, "credits.txt");
+ if (!FileSystem::exists(testfname))
+ {
+ // if the game is not run from the source directory, try to find
+ // the global install location
+ datadir = datadir.substr(0, datadir.rfind(INSTALL_SUBDIR_BIN));
+ datadir = FileSystem::join(datadir, INSTALL_SUBDIR_SHARE);
+ }
+
+ if (!PHYSFS_addToSearchPath(datadir.c_str(), 1))
+ {
+ log_warning << "Couldn't add '" << datadir << "' to physfs searchpath: " << PHYSFS_getLastError() << std::endl;
+ }
+ }