aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPFileManagerAdditions.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-11-09 21:23:38 +0000
committerBibiko <bibiko@eva.mpg.de>2010-11-09 21:23:38 +0000
commit7e34cf68b09d6b95bfa29e1233b44370adfd18b3 (patch)
treede57d0583b03513c7ae62ff77fdd2827b2702666 /Source/SPFileManagerAdditions.m
parent4dfdf313add14a802387cf69c95e85a2c0a7dca9 (diff)
downloadsequelpro-7e34cf68b09d6b95bfa29e1233b44370adfd18b3.tar.gz
sequelpro-7e34cf68b09d6b95bfa29e1233b44370adfd18b3.tar.bz2
sequelpro-7e34cf68b09d6b95bfa29e1233b44370adfd18b3.zip
• further preparations for user-definable bundle support
Diffstat (limited to 'Source/SPFileManagerAdditions.m')
-rw-r--r--Source/SPFileManagerAdditions.m24
1 files changed, 16 insertions, 8 deletions
diff --git a/Source/SPFileManagerAdditions.m b/Source/SPFileManagerAdditions.m
index dec4bd3f..2ea9fb71 100644
--- a/Source/SPFileManagerAdditions.m
+++ b/Source/SPFileManagerAdditions.m
@@ -35,13 +35,17 @@ NSString* const DirectoryLocationDomain = @"DirectoryLocationDomain";
@implementation NSFileManager (SPFileManagerAdditions)
-/*
+/**
* Return the application support folder of the current application for 'subDirectory'.
* If this folder doesn't exist it will be created. If 'subDirectory' == nil it only returns
* the application support folder of the current application.
*/
- (NSString*)applicationSupportDirectoryForSubDirectory:(NSString*)subDirectory error:(NSError **)errorOut
{
+ return [self applicationSupportDirectoryForSubDirectory:subDirectory createIfNotExists:YES error:errorOut];
+}
+- (NSString *)applicationSupportDirectoryForSubDirectory:(NSString*)subDirectory createIfNotExists:(BOOL)create error:(NSError **)errorOut;
+{
// Based on Matt Gallagher on 06 May 2010
//
// Permission is given to use this source code file, free of charge, in any
@@ -113,14 +117,18 @@ NSString* const DirectoryLocationDomain = @"DirectoryLocationDomain";
}
return nil;
}
-
- // Create the path if it doesn't exist
- NSError *error = nil;
- BOOL success = [self createDirectoryAtPath:resolvedPath withIntermediateDirectories:YES attributes:nil error:&error];
- if (!success) {
- if (errorOut) {
- *errorOut = error;
+
+ if(create) {
+ // Create the path if it doesn't exist
+ NSError *error = nil;
+ BOOL success = [self createDirectoryAtPath:resolvedPath withIntermediateDirectories:YES attributes:nil error:&error];
+ if (!success) {
+ if (errorOut) {
+ *errorOut = error;
+ }
+ return nil;
}
+ } else {
return nil;
}
}