From f4e2d1a30a6df8fef72c283af466c6aa21ec1280 Mon Sep 17 00:00:00 2001
From: Joshua Root <[EMAIL REDACTED]>
Date: Sat, 17 Sep 2022 11:08:07 +1000
Subject: [PATCH] Implement OS_GetExeName for macOS and FreeBSD
---
src/SDL12_compat.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/SDL12_compat.c b/src/SDL12_compat.c
index 2dddc1693..ddfd57943 100644
--- a/src/SDL12_compat.c
+++ b/src/SDL12_compat.c
@@ -1223,6 +1223,15 @@ static void OS_GetExeName(char *buf, const unsigned maxpath) {
buf[0] = '\0';
DosQueryModuleName(pib->pib_hmte, maxpath, buf);
}
+#elif defined(__APPLE__) || defined(__FREEBSD__)
+static void OS_GetExeName(char *buf, const unsigned maxpath) {
+ const char *progname = getprogname();
+ if (progname != NULL) {
+ strlcpy(buf, progname, maxpath);
+ } else {
+ buf[0] = '\0';
+ }
+}
#else
#warning Please implement this for your platform.
static void OS_GetExeName(char *buf, const unsigned maxpath) {