From 4c39f3ef9e67ddd6b05fd3c1fb00f5e3b1ca08d6 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 21 Jul 2012 00:48:13 -0400 Subject: Updated Application Support Category to create our ApSup directory if it's not there already. --- Classes/NSFileManager+DirectoryLocations.m | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'Classes') diff --git a/Classes/NSFileManager+DirectoryLocations.m b/Classes/NSFileManager+DirectoryLocations.m index 84cf307..9d0363a 100644 --- a/Classes/NSFileManager+DirectoryLocations.m +++ b/Classes/NSFileManager+DirectoryLocations.m @@ -12,7 +12,15 @@ - (NSString *)applicationSupportDirectory { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex: 0] : NSTemporaryDirectory(); - return [basePath stringByAppendingPathComponent:@"On Task"]; + NSString *applicationSupportPath = [basePath stringByAppendingPathComponent:@"On Task"]; + + if (![[NSFileManager defaultManager] fileExistsAtPath:applicationSupportPath]) { + if (![[NSFileManager defaultManager] createDirectoryAtPath:applicationSupportPath attributes:nil]) { + NSLog(@"Error: Could not create folder %@", applicationSupportPath); + } + } + + return applicationSupportPath; } @end -- cgit v1.2.3