COMMON: Restructuring how ApplicationSupport path is calculated and putting in Icons subdirectory

This commit is contained in:
Thunderforge 2022-06-30 13:21:42 -05:00 committed by Eugene Sandulenko
parent 6ff9cde60c
commit 80cc43a1d2
No known key found for this signature in database
GPG key ID: 014D387312D34F08
3 changed files with 16 additions and 9 deletions

View file

@ -262,18 +262,13 @@ Common::String OSystem_MacOSX::getDefaultLogFileName() {
} }
Common::String OSystem_MacOSX::getDefaultIconsPath() { Common::String OSystem_MacOSX::getDefaultIconsPath() {
const char *prefix = getenv("HOME"); const Common::String defaultIconsPath = getAppSupportPathMacOSX() + "/Icons";
if (prefix == nullptr) {
if (!Posix::assureDirectoryExists(defaultIconsPath)) {
return Common::String(); return Common::String();
} }
const Common::String appSupportFolder = Common::String(prefix) + "/Library/Application Support/ScummVM"; return defaultIconsPath;
if (!Posix::assureDirectoryExists(appSupportFolder)) {
return Common::String();
}
return appSupportFolder;
} }
Common::String OSystem_MacOSX::getScreenshotsPath() { Common::String OSystem_MacOSX::getScreenshotsPath() {

View file

@ -30,5 +30,6 @@ Common::U32String getTextFromClipboardMacOSX();
bool setTextInClipboardMacOSX(const Common::U32String &text); bool setTextInClipboardMacOSX(const Common::U32String &text);
Common::String getDesktopPathMacOSX(); Common::String getDesktopPathMacOSX();
Common::String getResourceAppBundlePathMacOSX(); Common::String getResourceAppBundlePathMacOSX();
Common::String getAppSupportPathMacOSX();
#endif #endif

View file

@ -118,3 +118,14 @@ Common::String getResourceAppBundlePathMacOSX() {
return Common::String(); return Common::String();
return Common::String([bundlePath fileSystemRepresentation]); return Common::String([bundlePath fileSystemRepresentation]);
} }
Common::String getAppSupportPathMacOSX() {
// See comments in getDesktopPathMacOSX() as we use the same methods
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
if ([paths count] == 0)
return Common::String();
NSString *path = [paths objectAtIndex:0];
if (path == nil)
return Common::String();
return Common::String([path fileSystemRepresentation]) + "/ScummVM";
}