mirror of https://github.com/OpenRCT2/OpenRCT2.git
Set path properly for OS X
This commit is contained in:
parent
d00c124e52
commit
b4b1624e08
|
@ -47,6 +47,9 @@
|
|||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#if defined(__APPLE__) && defined(__MACH__)
|
||||
#include <mach-o/dyld.h>
|
||||
#endif // defined(__APPLE__) && defined(__MACH__)
|
||||
#endif // defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
|
||||
|
||||
int gOpenRCT2StartupAction = STARTUP_ACTION_TITLE;
|
||||
|
@ -171,14 +174,23 @@ static void openrct2_set_exe_path()
|
|||
tempPath[exeDelimiterIndex] = L'\0';
|
||||
_wfullpath(exePath, tempPath, MAX_PATH);
|
||||
WideCharToMultiByte(CP_UTF8, 0, exePath, countof(exePath), gExePath, countof(gExePath), NULL, NULL);
|
||||
#else
|
||||
#else // _WIN32
|
||||
char exePath[MAX_PATH];
|
||||
#if defined(__APPLE__) && defined(__MACH__)
|
||||
int size = MAX_PATH;
|
||||
int result = _NSGetExecutablePath(exePath, &size);
|
||||
if (result != 0) {
|
||||
log_fatal("failed to get path");
|
||||
}
|
||||
exePath[MAX_PATH - 1] = '\0';
|
||||
#else // defined(__APPLE__) && defined(__MACH__)
|
||||
ssize_t bytesRead;
|
||||
bytesRead = readlink("/proc/self/exe", exePath, MAX_PATH);
|
||||
if (bytesRead == -1) {
|
||||
log_fatal("failed to read /proc/self/exe");
|
||||
}
|
||||
exePath[bytesRead - 1] = '\0';
|
||||
#endif // defined(__APPLE__) && defined(__MACH__)
|
||||
log_verbose("######################################## Setting exe path to %s", exePath);
|
||||
char *exeDelimiter = strrchr(exePath, platform_get_path_separator());
|
||||
if (exeDelimiter == NULL)
|
||||
|
|
Loading…
Reference in New Issue