mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
deploy-ng: implement getting executable path on Linux and macOS
This commit is contained in:
parent
409b241b40
commit
dac08490ee
@ -11,6 +11,10 @@
|
|||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#include <mach-o/dyld.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
@ -266,9 +270,21 @@ static void *map_blob(off_t offset, size_t size) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
runtime = fopen(buffer, "rb");
|
runtime = fopen(buffer, "rb");
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
char buffer[4096];
|
||||||
|
uint32_t bufsize = sizeof(buffer);
|
||||||
|
if (_NSGetExecutablePath(buffer, &bufsize) != 0) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
runtime = fopen(buffer, "rb");
|
||||||
#else
|
#else
|
||||||
// Let's hope that it was invoked with the executable name as first arg.
|
char buffer[4096];
|
||||||
runtime = fopen(argv[0], "rb");
|
ssize_t pathlen = readlink("/proc/self/exe", buffer, sizeof(buffer) - 1);
|
||||||
|
if (pathlen <= 0) {
|
||||||
|
perror("readlink(/proc/self/exe)");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
runtime = fopen(buffer, "rb");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Get offsets. In version 0, we read it from the end of the file.
|
// Get offsets. In version 0, we read it from the end of the file.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user