Merge pull request #4014 from ahir061/fix/macos-executable-directory
fix(libs): find the executable directory on macOS
This commit is contained in:
commit
f4b47ee51f
|
|
@ -6,6 +6,8 @@
|
|||
#include <system_error>
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#elif defined(__APPLE__)
|
||||
#include <mach-o/dyld.h>
|
||||
#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<char> 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
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@
|
|||
#include <vector>
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#elif defined(__APPLE__)
|
||||
#include <mach-o/dyld.h>
|
||||
#endif
|
||||
|
||||
static constexpr int SCE_NP_ENTITLEMENT_ACCESS_ERROR_PARAMETER = static_cast<int>(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<char> 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
|
||||
|
|
|
|||
Loading…
Reference in New Issue