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
#if defined(DATADIR) && defined(BINDIR)
#if defined(DATADIR) && defined(BINDIR) && defined(__unix__)
if ((foundPath == false)) {
currentpath = getDatPath();
foundPath = tryCustomPath(cfgType, fileName, currentpath);

View File

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

View File

@@ -876,10 +876,15 @@ namespace Shared {
}
}
#ifdef __linux__
#ifdef __unix__
std::string getExecPath() {
char buff[PATH_MAX];
#ifdef __linux__
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) {
buff[len] = '\0';
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 curPath = getExecPath();
printf("\n binary Path: %s", curPath.c_str());
const string subBinPath = endPathWithSlash(formatPath(TOSTRING(BINDIR))) + "glest";
printf("\n binary Path: %s", subBinPath.c_str());
eraseSubStr(curPath, subBinPath);
printf("\n path now: %s", curPath.c_str());
string datPath = curPath + endPathWithSlash(TOSTRING(DATADIR));
printf("\n what is this???: %s", TOSTRING(DATADIR));
printf("\n data path: %s", datPath.c_str());
return datPath;
}
#endif