From: Matthias Braun Date: Sat, 4 Jun 2005 13:54:15 +0000 (+0000) Subject: try current directory if reading /proc/exe/self failed X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=3b8479b944e306e18cb9cbdf8293fd28f3e6c115;p=supertux.git try current directory if reading /proc/exe/self failed SVN-Revision: 2561 --- diff --git a/src/main.cpp b/src/main.cpp index 1ce98bc05..8aa15323f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -97,27 +97,29 @@ static void find_directories() } // Detect datadir with some linux magic -#ifndef WIN32 if(datadir.empty()) { char exe_file[PATH_MAX]; +#ifdef WIN32 + strcpy(exe_file, "."); +#else if(readlink("/proc/self/exe", exe_file, PATH_MAX) < 0) { #ifdef DEBUG std::cerr << "Couldn't read /proc/self/exe \n"; #endif - } else { - std::string exedir = std::string(dirname(exe_file)) + "/"; - std::string testdir = exedir + "./data/"; - if(access(testdir.c_str(), F_OK) == 0) { - datadir = testdir; - } - - testdir = exedir + "../share/supertux/"; - if(datadir.empty() && access(testdir.c_str(), F_OK) == 0) { - datadir = testdir; - } - } - } + strcpy(exe_file, "."); + } #endif + std::string exedir = std::string(dirname(exe_file)) + "/"; + std::string testdir = exedir + "./data/"; + if(access(testdir.c_str(), F_OK) == 0) { + datadir = testdir; + } + + testdir = exedir + "../share/supertux/"; + if(datadir.empty() && access(testdir.c_str(), F_OK) == 0) { + datadir = testdir; + } + } #ifdef DATA_PREFIX // use default location