2016-07-28 00:20:33 +01:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
2021-12-26 18:47:58 +01:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
2016-07-28 00:20:33 +01:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2021-12-26 18:47:58 +01:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2016-07-28 00:20:33 +01:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Disable symbol overrides so that we can use system headers.
|
|
|
|
#define FORBIDDEN_SYMBOL_ALLOW_ALL
|
|
|
|
|
|
|
|
#include "backends/platform/sdl/macosx/macosx_wrapper.h"
|
2020-08-30 19:42:19 +01:00
|
|
|
#include "backends/platform/sdl/macosx/macosx-compat.h"
|
2016-07-28 00:20:33 +01:00
|
|
|
|
|
|
|
#include <Foundation/NSArray.h>
|
2022-05-18 16:32:29 +02:00
|
|
|
#include <Foundation/NSBundle.h>
|
2017-04-24 00:30:28 +01:00
|
|
|
#include <Foundation/NSPathUtilities.h>
|
|
|
|
#include <AvailabilityMacros.h>
|
2018-04-11 00:04:48 +01:00
|
|
|
#include <CoreFoundation/CFString.h>
|
2023-02-25 21:59:59 +01:00
|
|
|
#include <CoreFoundation/CFBundle.h>
|
2016-07-28 00:20:33 +01:00
|
|
|
|
2017-04-24 00:30:28 +01:00
|
|
|
Common::String getDesktopPathMacOSX() {
|
2021-08-03 17:23:27 +02:00
|
|
|
// The recommended method is to use NSFileManager.
|
2017-04-24 00:30:28 +01:00
|
|
|
// NSUrl *url = [[[NSFileManager defaultManager] URLsForDirectory:NSDesktopDirectory inDomains:NSUserDomainMask] firstObject];
|
|
|
|
// However it is only available in OS X 10.6+. So use NSSearchPathForDirectoriesInDomains instead (available since OS X 10.0)
|
|
|
|
// [NSArray firstObject] is also only available in OS X 10.6+. So we need to use [NSArray count] and [NSArray objectAtIndex:]
|
2017-04-26 08:38:55 +01:00
|
|
|
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDesktopDirectory, NSUserDomainMask, YES);
|
2017-04-24 00:30:28 +01:00
|
|
|
if ([paths count] == 0)
|
|
|
|
return Common::String();
|
|
|
|
NSString *path = [paths objectAtIndex:0];
|
|
|
|
if (path == nil)
|
|
|
|
return Common::String();
|
2022-02-05 01:45:27 -07:00
|
|
|
return Common::String([path fileSystemRepresentation]);
|
2017-04-26 08:38:55 +01:00
|
|
|
}
|
2022-05-06 18:59:38 +02:00
|
|
|
|
|
|
|
Common::String getResourceAppBundlePathMacOSX() {
|
2022-05-18 16:32:29 +02:00
|
|
|
NSString *bundlePath = [[NSBundle mainBundle] resourcePath];
|
|
|
|
if (bundlePath == nil)
|
|
|
|
return Common::String();
|
|
|
|
return Common::String([bundlePath fileSystemRepresentation]);
|
2022-05-06 18:59:38 +02:00
|
|
|
}
|
2022-06-30 13:21:42 -05:00
|
|
|
|
|
|
|
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";
|
2022-07-02 13:01:06 -05:00
|
|
|
}
|
2023-02-25 21:59:59 +01:00
|
|
|
|
|
|
|
Common::String getMacBundleName() {
|
|
|
|
NSString *appName = [[[NSBundle mainBundle] infoDictionary] objectForKey:(id)kCFBundleNameKey];
|
|
|
|
if (!appName)
|
|
|
|
return Common::String("ScummVM");
|
|
|
|
return Common::String([appName UTF8String]);
|
|
|
|
}
|