diff options
Diffstat (limited to 'drivers/unix/os_unix.cpp')
-rw-r--r-- | drivers/unix/os_unix.cpp | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index 359758290f..fd515d6dd3 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 @@ -353,7 +357,6 @@ Error OS_Unix::execute(const String& p_path, const List<String>& p_arguments,boo pid_t pid = fork(); ERR_FAIL_COND_V(pid<0,ERR_CANT_FORK); - //print("execute: %s\n",p_path.utf8().get_data()); if (pid==0) { @@ -390,8 +393,6 @@ Error OS_Unix::execute(const String& p_path, const List<String>& p_arguments,boo pid_t rpid = waitpid(pid,&status,0); if (r_exitcode) *r_exitcode=WEXITSTATUS(status); - - print("returned: %i, waiting for: %i\n",rpid,pid); } else { if (r_child_id) @@ -460,7 +461,7 @@ int OS_Unix::get_processor_count() const { String OS_Unix::get_data_dir() const { - String an = Globals::get_singleton()->get("application/name"); + String an = get_safe_application_name(); if (an!="") { @@ -494,7 +495,6 @@ String OS_Unix::get_executable_path() const { char buf[256]; memset(buf,0,256); readlink("/proc/self/exe", buf, sizeof(buf)); - //print_line("Exec path is:"+String(buf)); String b; b.parse_utf8(buf); if (b=="") { @@ -508,6 +508,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(); |