211 :(BOOL)create
212{
213 BOOL stale = NO;
216 NSString *name =
DESC(
@"snapshots-directory-name-mac");
217
218 if (snapshotDirDict !=
nil)
219 {
222 {
223 NSString *existingName = [[url path] lastPathComponent];
224 if ([existingName compare:name options:NSCaseInsensitiveSearch] != 0)
225 {
226
228 if (originalOldName ==
nil || [existingName compare:originalOldName options:NSCaseInsensitiveSearch] != 0)
229 {
231 }
232 }
233
234
235 Boolean inTrash = false;
236 const UInt8* utfPath = (UInt8*)[[url path] UTF8String];
237
238 OSStatus err = DetermineIfPathIsEnclosedByFolder(kOnAppropriateDisk, kTrashFolderType, utfPath, false, &inTrash);
239
240 if (err == noErr && inTrash ==
true) url =
nil;
241 }
242 }
243
245 {
246 NSString *path =
nil;
247 NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSDesktopDirectory, NSUserDomainMask, YES);
248 if ([searchPaths
count] > 0)
249 {
250 path = [[searchPaths objectAtIndex:0] stringByAppendingPathComponent:name];
251 }
252 url = [NSURL fileURLWithPath:path];
253
255 {
256 stale = YES;
257 if (create)
258 {
259 NSFileManager *fmgr = [NSFileManager defaultManager];
260 if (![fmgr fileExistsAtPath:path])
261 {
262#if OOLITE_LEOPARD
263 [fmgr createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:NULL];
264#else
265 [fmgr createDirectoryAtPath:path attributes:nil];
266#endif
267 }
268 }
269 }
270 }
271
272 if (stale)
273 {
275 if (snapshotDirDict !=
nil)
276 {
279 }
280 else
281 {
283 }
284 }
285
286 return url;
287}
#define kSnapshotsDirNameKey
#define kSnapshotsDirRefKey
@ kJAPersistentFileReferenceWithoutUI
@ kJAPersistentFileReferenceWithoutMounting
NSURL * JAURLFromPersistentFileReference(NSDictionary *fileRef, JAPersistentFileReferenceResolveFlags flags, BOOL *isStale)
NSDictionary * JAPersistentFileReferenceFromURL(NSURL *url)
static id GetPreference(NSString *key, Class expectedClass)
static void RemovePreference(NSString *key)