diff options
Diffstat (limited to 'Foundation/GTMNSString+FindFolder.m')
-rw-r--r-- | Foundation/GTMNSString+FindFolder.m | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/Foundation/GTMNSString+FindFolder.m b/Foundation/GTMNSString+FindFolder.m index 3a44174..2e847e3 100644 --- a/Foundation/GTMNSString+FindFolder.m +++ b/Foundation/GTMNSString+FindFolder.m @@ -62,12 +62,30 @@ // it already exists resultPath = subdirPath; } else if (doCreate) { - + parentFolderPath = [parentFolderPath stringByResolvingSymlinksInPath]; + NSDictionary* attrs = nil; + BOOL createdSubDir = NO; // create the subdirectory with the parent folder's attributes - NSDictionary* attrs = [fileMgr fileAttributesAtPath:parentFolderPath - traverseLink:YES]; - if ([fileMgr createDirectoryAtPath:subdirPath - attributes:attrs]) { +#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 + NSError *error = nil; + attrs = [fileMgr attributesOfItemAtPath:parentFolderPath error:&error]; + if (error) { + _GTMDevLog(@"Error %@ getting attributes of %@", + error, parentFolderPath); + } + createdSubDir = [fileMgr createDirectoryAtPath:subdirPath + withIntermediateDirectories:YES + attributes:attrs + error:&error]; + if (error) { + _GTMDevLog(@"Error %@ creating directory at %@", error, subdirPath); + } +#else + attrs = [fileMgr fileAttributesAtPath:parentFolderPath traverseLink:YES]; + createdSubDir = [fileMgr createDirectoryAtPath:subdirPath + attributes:attrs]; +#endif // MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 + if (createdSubDir) { resultPath = subdirPath; } } |