mirror of
https://github.com/Ryujinx/SDL.git
synced 2025-01-09 00:55:35 +00:00
[skip ci] Solaris getexecname() returns argv[0]
`argv[0]`/`getexexname()` are not always absolute paths by default and can be modified to anything the developer wants them to be. Consider using `readSymLink("/proc/self/path/a.out")` instead and `getexecname()` as the fallback, since the symlink will always be the correct absolute path (unless /proc is ot mounted, but it is by default on Solaris and Illumos platforms). (cherry picked from commit 4f5e9fd5bda0d58c2907f75fa4ea0c92c3a2525f)
This commit is contained in:
parent
8145212103
commit
0739d237ad
|
@ -208,16 +208,6 @@ SDL_GetBasePath(void)
|
||||||
SDL_free(cmdline);
|
SDL_free(cmdline);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if defined(__SOLARIS__)
|
|
||||||
const char *path = getexecname();
|
|
||||||
if ((path != NULL) && (path[0] == '/')) { /* must be absolute path... */
|
|
||||||
retval = SDL_strdup(path);
|
|
||||||
if (!retval) {
|
|
||||||
SDL_OutOfMemory();
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* is a Linux-style /proc filesystem available? */
|
/* is a Linux-style /proc filesystem available? */
|
||||||
if (!retval && (access("/proc", F_OK) == 0)) {
|
if (!retval && (access("/proc", F_OK) == 0)) {
|
||||||
|
@ -228,6 +218,8 @@ SDL_GetBasePath(void)
|
||||||
retval = readSymLink("/proc/curproc/file");
|
retval = readSymLink("/proc/curproc/file");
|
||||||
#elif defined(__NETBSD__)
|
#elif defined(__NETBSD__)
|
||||||
retval = readSymLink("/proc/curproc/exe");
|
retval = readSymLink("/proc/curproc/exe");
|
||||||
|
#elif defined(__SOLARIS__)
|
||||||
|
retval = readSymLink("/proc/self/path/a.out");
|
||||||
#elif defined(__QNXNTO__)
|
#elif defined(__QNXNTO__)
|
||||||
retval = SDL_LoadFile("/proc/self/exefile", NULL);
|
retval = SDL_LoadFile("/proc/self/exefile", NULL);
|
||||||
#else
|
#else
|
||||||
|
@ -245,6 +237,18 @@ SDL_GetBasePath(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(__SOLARIS__) /* try this as a fallback if /proc didn't pan out */
|
||||||
|
if (!retval) {
|
||||||
|
const char *path = getexecname();
|
||||||
|
if ((path != NULL) && (path[0] == '/')) { /* must be absolute path... */
|
||||||
|
retval = SDL_strdup(path);
|
||||||
|
if (!retval) {
|
||||||
|
SDL_OutOfMemory();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* If we had access to argv[0] here, we could check it for a path,
|
/* If we had access to argv[0] here, we could check it for a path,
|
||||||
or troll through $PATH looking for it, too. */
|
or troll through $PATH looking for it, too. */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue