From 73ae3d292f4614813b38a93424342a1ec5785646 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 20 Jan 2012 21:12:57 +0000 Subject: [PATCH] implement finding kak executable path on MacOS --- src/main.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main.cc b/src/main.cc index cd26d3d4..1c62cf7b 100644 --- a/src/main.cc +++ b/src/main.cc @@ -22,6 +22,10 @@ #include #include +#if defined(__APPLE__) +#include +#endif + using namespace Kakoune; using namespace std::placeholders; @@ -628,7 +632,14 @@ void exec_commands_in_runtime_file(const CommandParameters& params, const std::string& filename = params[0]; char buffer[2048]; +#if defined(__linux__) readlink("/proc/self/exe", buffer, 2048 - filename.length()); +#elif defined(__APPLE__) + uint32_t bufsize = 2048 - filename.length(); + _NSGetExecutablePath(buffer, &bufsize); +#else +# error "finding executable path is not implemented on this platform" +#endif char* ptr = strrchr(buffer, '/'); if (ptr) {