X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=lib%2Fapp%2Fsetup.cpp;h=c7972c470323bc8b2a025df720cb5fa51b9d9d49;hb=8e0bad9f82ccbc811a18edd7ce6c6f69c5bca082;hp=0a29dc4b948b5beabeea1262674aa56272294f9c;hpb=5a542dea3c6043703683b68fcaa774f6cb0d9127;p=supertux.git diff --git a/lib/app/setup.cpp b/lib/app/setup.cpp index 0a29dc4b9..c7972c470 100644 --- a/lib/app/setup.cpp +++ b/lib/app/setup.cpp @@ -67,7 +67,7 @@ void seticon(void); void usage(char * prog, int ret); /* Does the given file exist and is it accessible? */ -int FileSystem::faccessible(const std::string& filename) +bool FileSystem::faccessible(const std::string& filename) { struct stat filestat; if (stat(filename.c_str(), &filestat) == -1) @@ -84,7 +84,7 @@ int FileSystem::faccessible(const std::string& filename) } /* Can we write to this location? */ -int FileSystem::fwriteable(const std::string& filename) +bool FileSystem::fwriteable(const std::string& filename) { FILE* fi; fi = fopen(filename.c_str(), "wa"); @@ -97,7 +97,7 @@ int FileSystem::fwriteable(const std::string& filename) } /* Makes sure a directory is created in either the SuperTux home directory or the SuperTux base directory.*/ -int FileSystem::fcreatedir(const std::string& relative_dir) +bool FileSystem::fcreatedir(const std::string& relative_dir) { std::string path = st_dir + "/" + relative_dir + "/"; if(mkdir(path.c_str(),0755) != 0) @@ -252,6 +252,15 @@ std::set FileSystem::dfiles(const std::string& rel_path, const std return sdirs; } +std::string FileSystem::dirname(const std::string& filename) +{ + std::string::size_type p = filename.find_last_of('/'); + if(p == std::string::npos) + return ""; + + return filename.substr(0, p+1); +} + void Setup::init(const std::string& _package_name, const std::string& _package_symbol_name, const std::string& _package_version) @@ -294,7 +303,7 @@ void Setup::directories() // try current directory as datadir if(datadir.empty()) { - if(FileSystem::faccessible("./data/intro.txt")) + if(FileSystem::faccessible("./data/credits.txt")) datadir = "./data/"; } @@ -313,10 +322,10 @@ void Setup::directories() { std::string exedir = std::string(dirname(exe_file)) + "/"; - datadir = exedir + "../data/"; // SuperTux run from source dir + datadir = exedir + "./data/"; // SuperTux run from source dir if (access(datadir.c_str(), F_OK) != 0) { - datadir = exedir + "../../data/"; //SuperTux run from source dir (with libtool script) + datadir = exedir + "../../../../data/"; //SuperTux run from source dir (with libtool script) if (access(datadir.c_str(), F_OK) != 0) {