From: Matthias Braun Date: Sat, 4 Jun 2005 14:11:47 +0000 (+0000) Subject: fix for my latest commit X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=bebf5edbad6dd552eecc6acba93dca178286381e;p=supertux.git fix for my latest commit SVN-Revision: 2562 --- diff --git a/src/main.cpp b/src/main.cpp index 8aa15323f..950da90dc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -98,24 +98,26 @@ static void find_directories() // Detect datadir with some linux magic if(datadir.empty()) { - char exe_file[PATH_MAX]; + std::string exedir; #ifdef WIN32 - strcpy(exe_file, "."); + exedir = "."; #else - if(readlink("/proc/self/exe", exe_file, PATH_MAX) < 0) { + char exe_file[PATH_MAX]; + if(readlink("/proc/self/exe", exe_file, PATH_MAX) >= 0) { + exedir = std::string(dirname(exe_file)); + } else { #ifdef DEBUG std::cerr << "Couldn't read /proc/self/exe \n"; #endif - strcpy(exe_file, "."); + exedir = "."; } #endif - std::string exedir = std::string(dirname(exe_file)) + "/"; - std::string testdir = exedir + "./data/"; + std::string testdir = exedir + "/data/"; if(access(testdir.c_str(), F_OK) == 0) { datadir = testdir; } - testdir = exedir + "../share/supertux/"; + testdir = exedir + "/../share/supertux/"; if(datadir.empty() && access(testdir.c_str(), F_OK) == 0) { datadir = testdir; }