From bebf5edbad6dd552eecc6acba93dca178286381e Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Sat, 4 Jun 2005 14:11:47 +0000 Subject: [PATCH] fix for my latest commit SVN-Revision: 2562 --- src/main.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) 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; } -- 2.11.0