diff --git a/src/lay/lay/laySystemPaths.cc b/src/lay/lay/laySystemPaths.cc index 6e458716c..2f5645c32 100644 --- a/src/lay/lay/laySystemPaths.cc +++ b/src/lay/lay/laySystemPaths.cc @@ -30,6 +30,9 @@ #ifdef _WIN32 # include +#elif __APPLE__ +# include +# include #else # include #endif @@ -79,6 +82,15 @@ get_inst_path_internal () return tl::to_string (fi.absolutePath ()); } +#elif __APPLE__ + + char buffer[PROC_PIDPATHINFO_MAXSIZE]; + int ret = proc_pidpath (getpid (), buffer, sizeof (buffer)); + if (ret > 0) { + // TODO: does this correctly translate paths? (MacOS uses UTF-8 encoding with D-like normalization) + return tl::to_string (QFileInfo (QString::fromUtf8 (buffer)).absolutePath ()); + } + #else QFileInfo proc_exe (tl::to_qstring (tl::sprintf ("/proc/%d/exe", getpid ())));