From af77423f394c1dea40bb12dd80660469534e9bc9 Mon Sep 17 00:00:00 2001 From: Alexander von Gluck Date: Fri, 26 Jul 2024 16:05:23 -0500 Subject: [PATCH] icetime: Add proc_self_dirname for Haiku --- icetime/iceutil.cc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/icetime/iceutil.cc b/icetime/iceutil.cc index c9075a4d87..191f2da1b0 100644 --- a/icetime/iceutil.cc +++ b/icetime/iceutil.cc @@ -32,6 +32,10 @@ # include #endif +#ifdef __HAIKU__ +# include +#endif + #if defined(__FreeBSD__) || defined(__NetBSD__) # include #endif @@ -51,6 +55,22 @@ std::string proc_self_dirname() buflen--; return std::string(path, buflen); } +#elif defined(__HAIKU__) +std::string proc_self_dirname() +{ + std::string path; + + int32 cookie = 0; + image_info info; + while (get_next_image_info(B_CURRENT_TEAM, &cookie, &info) == B_OK) { + if (info.type == B_APP_IMAGE) { + path.assign(info.name); + return path; + } + } + fprintf(stderr, "fatal error: unable to get self dirname!"); + exit(EXIT_FAILURE); +} #elif defined(__FreeBSD__) || defined(__NetBSD__) std::string proc_self_dirname() {