mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-18 17:34:52 +00:00
Fix user data path on macOS.
This commit is contained in:
parent
225ca3ac5b
commit
43c0f313f2
2 changed files with 38 additions and 10 deletions
|
@ -4,6 +4,12 @@
|
|||
#include <unordered_map>
|
||||
#include "common/logging/log.h"
|
||||
#include "common/path_util.h"
|
||||
#include "common/scope_exit.h"
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <CoreFoundation/CFBundle.h>
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#ifndef MAX_PATH
|
||||
#ifdef _WIN32
|
||||
|
@ -19,7 +25,36 @@ namespace Common::FS {
|
|||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
#ifdef __APPLE__
|
||||
static std::filesystem::path GetBundleParentDirectory() {
|
||||
if (CFBundleRef bundle_ref = CFBundleGetMainBundle()) {
|
||||
if (CFURLRef bundle_url_ref = CFBundleCopyBundleURL(bundle_ref)) {
|
||||
SCOPE_EXIT {
|
||||
CFRelease(bundle_url_ref);
|
||||
};
|
||||
if (CFStringRef bundle_path_ref =
|
||||
CFURLCopyFileSystemPath(bundle_url_ref, kCFURLPOSIXPathStyle)) {
|
||||
SCOPE_EXIT {
|
||||
CFRelease(bundle_path_ref);
|
||||
};
|
||||
char app_bundle_path[MAXPATHLEN];
|
||||
if (CFStringGetFileSystemRepresentation(bundle_path_ref, app_bundle_path,
|
||||
sizeof(app_bundle_path))) {
|
||||
std::filesystem::path bundle_path{app_bundle_path};
|
||||
return bundle_path.parent_path();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return std::filesystem::current_path();
|
||||
}
|
||||
#endif
|
||||
|
||||
static auto UserPaths = [] {
|
||||
#ifdef __APPLE__
|
||||
std::filesystem::current_path(GetBundleParentDirectory());
|
||||
#endif
|
||||
|
||||
std::unordered_map<PathType, fs::path> paths;
|
||||
const auto user_dir = std::filesystem::current_path() / PORTABLE_DIR;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue