macOS: Change exe_path to be next to the .app bundle

This commit is contained in:
richardg867 2022-04-20 13:27:57 -03:00 committed by GitHub
parent 6a4b3fc7bb
commit 7e9dbffc3b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -398,9 +398,6 @@ pc_init(int argc, char *argv[])
{
char *ppath = NULL, *rpath = NULL;
char *cfg = NULL, *p;
#if !defined(__APPLE__) && !defined(_WIN32)
char *appimage;
#endif
char temp[2048];
struct tm *info;
time_t now;
@ -413,15 +410,20 @@ pc_init(int argc, char *argv[])
/* Grab the executable's full path. */
plat_get_exe_name(exe_path, sizeof(exe_path)-1);
p = path_get_filename(exe_path);
p = path_get_filename(exe_path);
*p = '\0';
#if !defined(_WIN32) && !defined(__APPLE__)
/* Grab the actual path if we are an AppImage. */
appimage = getenv("APPIMAGE");
if (appimage && (appimage[0] != '\0')) {
path_get_dirname(exe_path, appimage);
#if defined(__APPLE__)
c = strlen(exe_path);
if ((c >= 16) && !strcmp(&exe_path[c - 16], "/Contents/MacOS/")) {
exe_path[c - 16] = '\0';
p = path_get_filename(exe_path);
*p = '\0';
}
#elif !defined(_WIN32)
/* Grab the actual path if we are an AppImage. */
p = getenv("APPIMAGE");
if (p && (p[0] != '\0'))
path_get_dirname(exe_path, p);
#endif
path_slash(exe_path);