79- (IBAction) showExpansionPacks:sender
84 for (NSString *path in paths) {
85 if ([
self addOnsExistAtPath:path]) {
92 for (NSString *path in paths) {
93 if ([
self isDirectoryAtPath:path]) {
101 withIntermediateDirectories:YES
115- (BOOL) addOnsExistAtPath:(NSString *)path
117 if (![
self isDirectoryAtPath:path])
return NO;
119 NSWorkspace *workspace = NSWorkspace.sharedWorkspace;
120 for (NSString *subPath in [NSFileManager.defaultManager enumeratorAtPath:path]) {
121 subPath = [
path stringByAppendingPathComponent:subPath];
122 NSString *type = [
workspace typeOfFile:subPath error:NULL];
123 if ([workspace type:type conformsToType:
@"org.aegidian.oolite.expansion"])
return YES;
211- (NSURL *) snapshotsURLCreatingIfNeeded:(BOOL)create
216 NSString *name =
DESC(
@"snapshots-directory-name-mac");
218 if (snapshotDirDict !=
nil)
223 NSString *existingName = [[
url path] lastPathComponent];
224 if ([existingName compare:name options:NSCaseInsensitiveSearch] != 0)
228 if (originalOldName ==
nil || [existingName compare:originalOldName options:NSCaseInsensitiveSearch] != 0)
235 Boolean inTrash =
false;
236 const UInt8* utfPath = (UInt8*)[[url path] UTF8String];
238 OSStatus err = DetermineIfPathIsEnclosedByFolder(kOnAppropriateDisk, kTrashFolderType, utfPath,
false, &inTrash);
240 if (err == noErr && inTrash ==
true) url =
nil;
246 NSString *path =
nil;
247 NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSDesktopDirectory, NSUserDomainMask, YES);
248 if ([searchPaths
count] > 0)
250 path = [[
searchPaths objectAtIndex:0] stringByAppendingPathComponent:name];
252 url = [
NSURL fileURLWithPath:path];
260 if (![fmgr fileExistsAtPath:path])
263 [
fmgr createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:NULL];
265 [
fmgr createDirectoryAtPath:path attributes:nil];
275 if (snapshotDirDict !=
nil)
307 static NSString *basePath =
nil;
312 basePath = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0];
313 basePath = [basePath stringByAppendingPathComponent:@"Logs"];
314 basePath = [basePath stringByAppendingPathComponent:@"Oolite"];
316 BOOL exists, directory;
317 NSFileManager *fmgr = [NSFileManager defaultManager];
319 exists = [fmgr fileExistsAtPath:basePath isDirectory:&directory];
329 if (![fmgr createDirectoryAtPath:basePath withIntermediateDirectories:YES attributes:
nil error:NULL])
345 return [NSArray arrayWithObjects:
346 [[[[NSHomeDirectory() stringByAppendingPathComponent:@"Library"]
347 stringByAppendingPathComponent:@"Application Support"]
348 stringByAppendingPathComponent:@"Oolite"]
349 stringByAppendingPathComponent:@"AddOns"],
350 [[[[NSBundle mainBundle] bundlePath]
351 stringByDeletingLastPathComponent]
352 stringByAppendingPathComponent:@"AddOns"],
354 stringByAppendingPathComponent:@".Oolite"]
355 stringByAppendingPathComponent:@"AddOns"],