From f30f3e8a84a7ba5d56e33acc6a237144dd9ca7a1 Mon Sep 17 00:00:00 2001 From: Ahir Barman Maji <191682168+ahir061@users.noreply.github.com> Date: Mon, 12 Oct 2026 02:38:05 +0530 Subject: [PATCH] fix(libs): find the executable directory on macOS libSceFont and libSceNpEntitlementAccess located the executable through /proc/self/exe, which macOS does not have, so finding the system fonts and the entitlements file threw there. Use _NSGetExecutablePath and resolve the path with std::filesystem::canonical on macOS. Linux and Windows are unchanged. Co-Authored-By: Claude Opus 5.5 --- core/libs/prx/libSceFont/src/SystemFont.cpp | 11 +++++++++++ core/libs/prx/libSceNpEntitlementAccess/Export.cpp | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/core/libs/prx/libSceFont/src/SystemFont.cpp b/core/libs/prx/libSceFont/src/SystemFont.cpp index bf1281380..f164d8646 100644 --- a/core/libs/prx/libSceFont/src/SystemFont.cpp +++ b/core/libs/prx/libSceFont/src/SystemFont.cpp @@ -6,6 +6,8 @@ #include #ifdef _WIN32 #include +#elif defined(__APPLE__) +#include #endif #include "prx/libSceFont/include/FontInternal.hpp" @@ -91,6 +93,15 @@ std::filesystem::path ExecutableDirectory() { const auto length = GetModuleFileNameW(nullptr, module, MAX_PATH); if (length == 0 || length == MAX_PATH) throw std::runtime_error("libSceFont: cannot locate the executable"); return std::filesystem::path(module).parent_path(); +#elif defined(__APPLE__) + std::uint32_t size = 0; + _NSGetExecutablePath(nullptr, &size); + std::vector executable(size); + std::error_code error; + std::filesystem::path path; + if (_NSGetExecutablePath(executable.data(), &size) == 0) path = std::filesystem::canonical(executable.data(), error); + if (path.empty()) throw std::runtime_error("libSceFont: cannot locate the executable"); + return path.parent_path(); #else return std::filesystem::read_symlink("/proc/self/exe").parent_path(); #endif diff --git a/core/libs/prx/libSceNpEntitlementAccess/Export.cpp b/core/libs/prx/libSceNpEntitlementAccess/Export.cpp index d0bc1f710..1b5a443de 100644 --- a/core/libs/prx/libSceNpEntitlementAccess/Export.cpp +++ b/core/libs/prx/libSceNpEntitlementAccess/Export.cpp @@ -12,6 +12,8 @@ #include #ifdef _WIN32 #include +#elif defined(__APPLE__) +#include #endif static constexpr int SCE_NP_ENTITLEMENT_ACCESS_ERROR_PARAMETER = static_cast(0x80558003); @@ -28,6 +30,15 @@ std::filesystem::path EntitlementsPath() { const auto length = GetModuleFileNameW(nullptr, module, MAX_PATH); if (length == 0 || length == MAX_PATH) throw std::runtime_error("NpEntitlementAccess: cannot locate the executable"); return std::filesystem::path(module).parent_path() / "anyps5-entitlements.ini"; +#elif defined(__APPLE__) + std::uint32_t size = 0; + _NSGetExecutablePath(nullptr, &size); + std::vector executable(size); + std::error_code error; + std::filesystem::path path; + if (_NSGetExecutablePath(executable.data(), &size) == 0) path = std::filesystem::canonical(executable.data(), error); + if (path.empty()) throw std::runtime_error("NpEntitlementAccess: cannot locate the executable"); + return path.parent_path() / "anyps5-entitlements.ini"; #else return std::filesystem::read_symlink("/proc/self/exe").parent_path() / "anyps5-entitlements.ini"; #endif