From 4c5326dcd34f1ffa221a884d0bfb30a44c680848 Mon Sep 17 00:00:00 2001
From: Glenn Butcher <glenn.butcher@gmail.com>
Date: Wed, 5 Jun 2024 15:50:15 -0600
Subject: [PATCH] fix: add Apple logic to GetExeDir()

---
 src/fileutil.cpp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/fileutil.cpp b/src/fileutil.cpp
index 2693d3d..27fa434 100644
--- a/src/fileutil.cpp
+++ b/src/fileutil.cpp
@@ -82,6 +82,11 @@ std::string getExeDir(std::string filename)
 	dir = std::string(exePath);
 	dir.erase(dir.find_last_of('\\'));
 	if (filename != "") dir.append("\\"+filename);
+#elif __APPLE__
+	char buf [PATH_MAX];
+	uint32_t bufsize = PATH_MAX;
+	if(!_NSGetExecutablePath(buf, &bufsize))
+	dir = std::string(buf);
 #else
 	char exePath[PATH_MAX];
 	size_t len = readlink("/proc/self/exe", exePath, sizeof(exePath));
