2012-05-07 20:18:01 +00:00
|
|
|
//
|
|
|
|
// MPAppDelegate.m
|
|
|
|
// MasterPassword
|
|
|
|
//
|
|
|
|
// Created by Maarten Billemont on 24/11/11.
|
|
|
|
// Copyright (c) 2011 Lyndir. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "MPAppDelegate_Shared.h"
|
|
|
|
|
2012-05-11 20:45:05 +00:00
|
|
|
@implementation MPAppDelegate_Shared
|
2012-05-07 20:18:01 +00:00
|
|
|
|
2012-05-11 20:45:05 +00:00
|
|
|
@synthesize key;
|
|
|
|
@synthesize keyID;
|
|
|
|
|
|
|
|
+ (MPAppDelegate_Shared *)get {
|
2012-05-07 20:18:01 +00:00
|
|
|
|
2012-05-11 15:04:51 +00:00
|
|
|
#if TARGET_OS_IPHONE
|
2012-05-11 20:45:05 +00:00
|
|
|
return (MPAppDelegate_Shared *)[UIApplication sharedApplication].delegate;
|
2012-05-07 20:18:01 +00:00
|
|
|
#elif defined (__MAC_OS_X_VERSION_MIN_REQUIRED)
|
2012-05-11 20:45:05 +00:00
|
|
|
return (MPAppDelegate_Shared *)[NSApplication sharedApplication].delegate;
|
2012-05-07 20:18:01 +00:00
|
|
|
#else
|
|
|
|
#error Unsupported OS.
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSURL *)applicationFilesDirectory {
|
|
|
|
|
2012-05-11 15:04:51 +00:00
|
|
|
#if TARGET_OS_IPHONE
|
2012-05-07 20:18:01 +00:00
|
|
|
return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
|
|
|
|
#else
|
|
|
|
NSURL *appSupportURL = [[[NSFileManager defaultManager] URLsForDirectory:NSApplicationSupportDirectory inDomains:NSUserDomainMask] lastObject];
|
|
|
|
NSURL *applicationFilesDirectory = [appSupportURL URLByAppendingPathComponent:@"com.lyndir.lhunath.MasterPassword"];
|
|
|
|
|
|
|
|
NSError *error = nil;
|
|
|
|
[[NSFileManager defaultManager] createDirectoryAtURL:applicationFilesDirectory withIntermediateDirectories:YES attributes:nil error:&error];
|
|
|
|
if (error)
|
|
|
|
err(@"Couldn't create application directory: %@, error occurred: %@", applicationFilesDirectory, error);
|
|
|
|
|
|
|
|
return applicationFilesDirectory;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|