File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,6 +31,9 @@ static LARGE_INTEGER yo;
3131#include < stdlib.h>
3232#include < sys/time.h>
3333#include < unistd.h>
34+ #ifdef __APPLE__
35+ #include < mach-o/dyld.h>
36+ #endif
3437#define SET_TICKER_RESOLUTION (ms )
3538#define LIBRARY_OPEN (path ) dlopen(path, RTLD_LAZY | RTLD_LOCAL )
3639#define LIBRARY_OPEN_GLOBAL (path ) dlopen(path, RTLD_LAZY | RTLD_GLOBAL )
@@ -153,6 +156,19 @@ ghc::filesystem::path GetExecutablePath()
153156 {
154157 return ghc::filesystem::path ();
155158 }
159+ #elif defined(__APPLE__)
160+ char path[4096 ] = { 0 };
161+ uint32_t size = sizeof (path);
162+ if (_NSGetExecutablePath (path, &size) == 0 )
163+ {
164+ std::error_code ec;
165+ auto canonicalPath = ghc::filesystem::canonical (path, ec);
166+ return ec ? ghc::filesystem::path (path) : canonicalPath;
167+ }
168+ else
169+ {
170+ return ghc::filesystem::path ();
171+ }
156172#else
157173 return ghc::filesystem::canonical (" /proc/self/exe" );
158174#endif
You can’t perform that action at this time.
0 commit comments