mirror of
https://github.com/macports/macports-ports.git
synced 2026-07-12 18:20:25 -07:00
47 lines
1.4 KiB
Diff
47 lines
1.4 KiB
Diff
NSFileManager URLForDirectory:inDomain:appropriateForURL:create:error: was added in Mac OS X 10.6.
|
|
|
|
Replace with NSSearchPathForDirectoriesInDomains() to support all versions of Mac OS X.
|
|
|
|
NSDownloadsDirectory was added in Mac OS X 10.5, fall back to NSDesktopDirectory on Tiger.
|
|
|
|
--- ./src/commonui/fz_paths_osx.mm.orig 2021-10-26 14:12:19.000000000 +0200
|
|
+++ ./src/commonui/fz_paths_osx.mm 2023-03-25 20:24:46.000000000 +0100
|
|
@@ -1,3 +1,5 @@
|
|
+#include <AvailabilityMacros.h>
|
|
+#include <Foundation/NSPathUtilities.h>
|
|
#include <Foundation/NSFileManager.h>
|
|
#include <Foundation/NSURL.h>
|
|
|
|
@@ -17,12 +19,25 @@
|
|
{
|
|
static char const* path = 0;
|
|
if (!path) {
|
|
- NSURL* url = [[NSFileManager defaultManager] URLForDirectory:NSDownloadsDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:nil];
|
|
- if (url) {
|
|
- path = strdup(url.path.UTF8String);
|
|
- }
|
|
- else {
|
|
- path = "";
|
|
+ path = "";
|
|
+
|
|
+ NSArray *paths = NSSearchPathForDirectoriesInDomains(
|
|
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050
|
|
+ NSDownloadsDirectory,
|
|
+#else
|
|
+ NSDesktopDirectory,
|
|
+#endif
|
|
+ NSUserDomainMask,
|
|
+ YES);
|
|
+ NSFileManager *fileManager = [NSFileManager defaultManager];
|
|
+ for (int i = 0; i < [paths count]; ++i) {
|
|
+ id searchdir = [paths objectAtIndex:i];
|
|
+
|
|
+ BOOL isDir;
|
|
+ if ([fileManager fileExistsAtPath:searchdir isDirectory:&isDir] && isDir) {
|
|
+ path = strdup([searchdir UTF8String]);
|
|
+ break;
|
|
+ }
|
|
}
|
|
}
|
|
return path;
|