Implement getCurrentExecutableLocation() on FreeBSD (#3688)
This commit is contained in:
parent
bec1c319f6
commit
75076106b9
@ -34,6 +34,11 @@
|
||||
# include <errno.h>
|
||||
#endif
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
|
||||
#ifdef ANDROID
|
||||
#include <dlfcn.h>
|
||||
#include <fstream>
|
||||
@ -58,6 +63,15 @@ std::string SeparateProcess::getCurrentExecutableLocation()
|
||||
return file_manager->getFileSystem()->getAbsolutePath(path).c_str();
|
||||
}
|
||||
return "";
|
||||
#elif defined (__FreeBSD__)
|
||||
char path[PATH_MAX];
|
||||
size_t len = PATH_MAX;
|
||||
const int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1};
|
||||
if (sysctl(&mib[0], 4, &path, &len, NULL, 0) == 0)
|
||||
{
|
||||
return file_manager->getFileSystem()->getAbsolutePath(path).c_str();
|
||||
}
|
||||
return "";
|
||||
#else
|
||||
// Assume Linux
|
||||
return file_manager->getFileSystem()->getAbsolutePath("/proc/self/exe")
|
||||
|
Loading…
Reference in New Issue
Block a user