From 8e3dcd5a02fc541b23687812fb19afa724e776c1 Mon Sep 17 00:00:00 2001 From: "mark@chromium.org" Date: Thu, 9 Feb 2012 20:31:08 +0000 Subject: [PATCH] createDirectoryAtPath:attributes: is deprecated, use the suggested (10.5+) replacement. Patch by Nico Weber Review URL: https://breakpad.appspot.com/349001/ git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@915 4c0a9323-5329-0410-9bdc-e9ce6186880e --- src/client/mac/crash_generation/ConfigFile.mm | 49 ++----------------- 1 file changed, 4 insertions(+), 45 deletions(-) diff --git a/src/client/mac/crash_generation/ConfigFile.mm b/src/client/mac/crash_generation/ConfigFile.mm index 315d07f9..b5e918df 100644 --- a/src/client/mac/crash_generation/ConfigFile.mm +++ b/src/client/mac/crash_generation/ConfigFile.mm @@ -55,55 +55,14 @@ namespace google_breakpad { BOOL EnsureDirectoryPathExists(NSString *dirPath) { NSFileManager *mgr = [NSFileManager defaultManager]; - // If we got a relative path, prepend the current directory - if (![dirPath isAbsolutePath]) - dirPath = - [[mgr currentDirectoryPath] stringByAppendingPathComponent:dirPath]; - - NSString *path = dirPath; - - // Ensure that no file exists within the path which would block creation - while (1) { - BOOL isDir; - if ([mgr fileExistsAtPath:path isDirectory:&isDir]) { - if (isDir) - break; - - return NO; - } - - path = [path stringByDeletingLastPathComponent]; - } - - // Path now contains the first valid directory (or is empty) - if (![path length]) - return NO; - - NSString *common = - [dirPath commonPrefixWithString:path options:NSLiteralSearch]; - - // If everything is good - if ([common isEqualToString:dirPath]) - return YES; - - // Break up the difference into components - NSString *diff = [dirPath substringFromIndex:[common length] + 1]; - NSArray *components = [diff pathComponents]; - NSUInteger count = [components count]; - - // Rebuild the path one component at a time NSDictionary *attrs = [NSDictionary dictionaryWithObject:[NSNumber numberWithUnsignedLong:0750] forKey:NSFilePosixPermissions]; - path = common; - for (NSUInteger i = 0; i < count; ++i) { - path = [path stringByAppendingPathComponent:[components objectAtIndex:i]]; - if (![mgr createDirectoryAtPath:path attributes:attrs]) - return NO; - } - - return YES; + return [mgr createDirectoryAtPath:dirPath + withIntermediateDirectories:YES + attributes:attrs + error:nil]; } //=============================================================================