mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-24 06:37:49 +08:00
32 lines
1.1 KiB
Diff
32 lines
1.1 KiB
Diff
|
diff --git a/src/futils.cpp b/src/futils.cpp
|
||
|
index 3e30c9996..c746838d5 100644
|
||
|
--- a/src/futils.cpp
|
||
|
+++ b/src/futils.cpp
|
||
|
@@ -38,6 +38,10 @@ namespace fs = std::experimental::filesystem;
|
||
|
#include <unistd.h> // for stat()
|
||
|
#endif
|
||
|
|
||
|
+#if __has_include(<mach-o/dyld.h>)
|
||
|
+#include <mach-o/dyld.h> // for _NSGetExecutablePath()
|
||
|
+#endif
|
||
|
+
|
||
|
#if defined(__FreeBSD__)
|
||
|
// clang-format off
|
||
|
#include <sys/mount.h>
|
||
|
@@ -360,9 +364,12 @@ std::string getProcessPath() {
|
||
|
TCHAR pathbuf[MAX_PATH];
|
||
|
GetModuleFileName(nullptr, pathbuf, MAX_PATH);
|
||
|
auto path = fs::path(pathbuf);
|
||
|
-#elif __has_include(<libproc.h>)
|
||
|
- char pathbuf[PROC_PIDPATHINFO_MAXSIZE];
|
||
|
- proc_pidpath(getpid(), pathbuf, sizeof(pathbuf));
|
||
|
+#elif defined(__APPLE__)
|
||
|
+ char pathbuf[2048];
|
||
|
+ uint32_t size = sizeof(pathbuf);
|
||
|
+ const int get_exec_path_failure = _NSGetExecutablePath(pathbuf, &size);
|
||
|
+ if (get_exec_path_failure)
|
||
|
+ return "unknown"; // pathbuf not big enough
|
||
|
auto path = fs::path(pathbuf);
|
||
|
#elif defined(__sun__)
|
||
|
auto path = fs::read_symlink(Internal::stringFormat("/proc/%d/path/a.out", getpid()));
|