mirror of
https://github.com/Zelda64Recomp/Zelda64Recomp
synced 2026-07-11 15:29:05 -04:00
Use Application Support directory on macOS. (#553)
This commit is contained in:
@@ -162,6 +162,13 @@ std::filesystem::path zelda64::get_app_folder_path() {
|
||||
return std::filesystem::path{getenv("APP_FOLDER_PATH")};
|
||||
}
|
||||
|
||||
#if defined(__APPLE__)
|
||||
const auto supportdir = zelda64::get_application_support_directory();
|
||||
if (supportdir) {
|
||||
return *supportdir / zelda64::program_id;
|
||||
}
|
||||
#endif
|
||||
|
||||
const char *homedir;
|
||||
|
||||
if ((homedir = getenv("HOME")) == nullptr) {
|
||||
|
||||
@@ -12,6 +12,15 @@ namespace zelda64 {
|
||||
});
|
||||
}
|
||||
|
||||
std::optional<std::filesystem::path> get_application_support_directory() {
|
||||
NSArray *dirs = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
|
||||
if ([dirs count] > 0) {
|
||||
NSString *dir = [dirs firstObject];
|
||||
return std::filesystem::path([dir UTF8String]);
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::filesystem::path get_bundle_resource_directory() {
|
||||
NSString *bundlePath = [[NSBundle mainBundle] resourcePath];
|
||||
return std::filesystem::path([bundlePath UTF8String]);
|
||||
|
||||
Reference in New Issue
Block a user