Made a few macro corrections (to avoid breaking windows builds) and removed unwanted prints.

This commit is contained in:
Jammyjamjamman
2019-04-12 21:43:10 +01:00
parent 35b08573f8
commit 417908c91d
3 changed files with 9 additions and 9 deletions

View File

@@ -264,7 +264,7 @@ namespace Game {
#endif #endif
#if defined(DATADIR) && defined(BINDIR) #if defined(DATADIR) && defined(BINDIR) && defined(__unix__)
if ((foundPath == false)) { if ((foundPath == false)) {
currentpath = getDatPath(); currentpath = getDatPath();
foundPath = tryCustomPath(cfgType, fileName, currentpath); foundPath = tryCustomPath(cfgType, fileName, currentpath);

View File

@@ -53,7 +53,7 @@ namespace Shared {
namespace Util { namespace Util {
string Properties::applicationPath = ""; string Properties::applicationPath = "";
#if defined(DATADIR) && defined(BINDIR) #if defined(DATADIR) && defined(BINDIR) && defined(__unix__)
string Properties::applicationDataPath = getDatPath(); string Properties::applicationDataPath = getDatPath();
#else #else
string Properties::applicationDataPath = ""; string Properties::applicationDataPath = "";

View File

@@ -876,10 +876,15 @@ namespace Shared {
} }
} }
#ifdef __linux__ #ifdef __unix__
std::string getExecPath() { std::string getExecPath() {
char buff[PATH_MAX]; char buff[PATH_MAX];
#ifdef __linux__
ssize_t len = ::readlink("/proc/self/exe", buff, sizeof(buff)-1); ssize_t len = ::readlink("/proc/self/exe", buff, sizeof(buff)-1);
#else
// e.g. for FreeBSD with procfs installed.
ssize_t len = ::readlink("/proc/curproc/file", buff, sizeof(buff)-1);
#endif // __linux__
if (len != -1) { if (len != -1) {
buff[len] = '\0'; buff[len] = '\0';
return std::string(buff); return std::string(buff);
@@ -901,17 +906,12 @@ namespace Shared {
} }
#if defined(DATADIR) && defined(BINDIR) #if defined(DATADIR) && defined(BINDIR) && defined(__unix__)
string getDatPath() { string getDatPath() {
string curPath = getExecPath(); string curPath = getExecPath();
printf("\n binary Path: %s", curPath.c_str());
const string subBinPath = endPathWithSlash(formatPath(TOSTRING(BINDIR))) + "glest"; const string subBinPath = endPathWithSlash(formatPath(TOSTRING(BINDIR))) + "glest";
printf("\n binary Path: %s", subBinPath.c_str());
eraseSubStr(curPath, subBinPath); eraseSubStr(curPath, subBinPath);
printf("\n path now: %s", curPath.c_str());
string datPath = curPath + endPathWithSlash(TOSTRING(DATADIR)); string datPath = curPath + endPathWithSlash(TOSTRING(DATADIR));
printf("\n what is this???: %s", TOSTRING(DATADIR));
printf("\n data path: %s", datPath.c_str());
return datPath; return datPath;
} }
#endif #endif