diff options
author | Rémi Verschelde <remi@verschelde.fr> | 2016-04-20 19:09:46 +0200 |
---|---|---|
committer | Rémi Verschelde <remi@verschelde.fr> | 2016-04-20 19:09:46 +0200 |
commit | 1ea4b8e2dc61b39e78fb1691f738a03091ee2138 (patch) | |
tree | 4bb17a37e213a75ce9b4a17a0314b3212bbb20c0 | |
parent | 30e5df6e21911a1952e5301600c036e603821fc4 (diff) | |
parent | e5c1a2c3f7bc97e75f885ea1af6d1ac0cf1efb46 (diff) |
Merge pull request #4382 from kurikaesu/get-executable-path-fixes-osx-javascript
Implements get_executable_path for OS X should proc_pidpath in os_osx…
-rw-r--r-- | drivers/unix/os_unix.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index 359758290f..4fa46b16cd 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -44,6 +44,10 @@ #include "stream_peer_tcp_posix.h" #include "packet_peer_udp_posix.h" +#ifdef __APPLE__ +#include <mach-o/dyld.h> +#endif + #ifdef __FreeBSD__ #include <sys/param.h> #endif @@ -508,6 +512,23 @@ String OS_Unix::get_executable_path() const { realpath(OS::get_executable_path().utf8().get_data(), resolved_path); return String(resolved_path); +#elif defined(__APPLE__) + char temp_path[1]; + uint32_t buff_size=1; + _NSGetExecutablePath(temp_path, &buff_size); + + char* resolved_path = new char[buff_size + 1]; + + if (_NSGetExecutablePath(resolved_path, &buff_size) == 1) + WARN_PRINT("MAXPATHLEN is too small"); + + String path(resolved_path); + delete[] resolved_path; + + return path; +#elif defined(EMSCRIPTEN) + // We return nothing + return String(); #else ERR_PRINT("Warning, don't know how to obtain executable path on this OS! Please override this function properly."); return OS::get_executable_path(); |