From 4f89cfe836e82f9445b98d733d6eb54b86e609d2 Mon Sep 17 00:00:00 2001 From: "gtm.daemon" Date: Fri, 14 May 2010 19:35:54 +0000 Subject: [Author: dmaclach] There are still a couple of errors occurring, but this fixes up the majority of stuff. I figured I'd send it out to you now to take a look at in the morning, and then we can clean up the last couple of issues. Not quite sure what to do about the naming of data files so that we can encompass ranges of system version (e.g. this file applies to 10.5 and 10.6 but not 10.4 or 10.7. R=thomasvl DELTA=10598 (10211 added, 70 deleted, 317 changed) --- Foundation/GTMNSFileManager+PathTest.m | 51 ++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 15 deletions(-) (limited to 'Foundation/GTMNSFileManager+PathTest.m') diff --git a/Foundation/GTMNSFileManager+PathTest.m b/Foundation/GTMNSFileManager+PathTest.m index 86f365f..5e4f845 100644 --- a/Foundation/GTMNSFileManager+PathTest.m +++ b/Foundation/GTMNSFileManager+PathTest.m @@ -28,20 +28,22 @@ - (void)setUp { // make a directory to scribble in - baseDir_ = - [[NSTemporaryDirectory() - stringByAppendingPathComponent:@"GTMNSFileManager_PathTest"] retain]; - if (baseDir_) { - NSFileManager *fm = [NSFileManager defaultManager]; - if (![fm fileExistsAtPath:baseDir_] && - ![fm createDirectoryAtPath:baseDir_ attributes:nil]) { - // COV_NF_START - // if the dir exists or we failed to create it, drop the baseDir_ - [baseDir_ release]; - baseDir_ = nil; - // COV_NF_END - } - } + NSString *base = NSTemporaryDirectory(); + base = [base stringByAppendingPathComponent:@"GTMNSFileManager_PathTest"]; + NSFileManager *fm = [NSFileManager defaultManager]; + STAssertFalse([fm fileExistsAtPath:base], @"File exists at %@", base); +#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 + NSError *error = nil; + STAssertTrue([fm createDirectoryAtPath:base + withIntermediateDirectories:YES + attributes:nil + error:&error], + @"Unable to create %@: %@", base, error); +#else + STAssertTrue([fm createDirectoryAtPath:baseDir_ attributes:nil], + @"Unable to create %@", base); +#endif + baseDir_ = [base retain]; } - (void)tearDown { @@ -52,7 +54,7 @@ NSError *error = nil; [fm removeItemAtPath:baseDir_ error:&error]; STAssertNil(error, - @"Unable to delete %@: %@", baseDir_, [error description]); + @"Unable to delete %@: %@", baseDir_, error); #else [fm removeFileAtPath:baseDir_ handler:nil]; #endif @@ -135,7 +137,16 @@ NSString *testDir = nil; if ([testDirs[i] length]) { testDir = [baseDir_ stringByAppendingPathComponent:testDirs[i]]; +#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 + NSError *error = nil; + STAssertTrue([fm createDirectoryAtPath:testDir + withIntermediateDirectories:YES + attributes:nil + error:&error], + @"Can't create %@ (%@)", testDir, error); +#else STAssertTrue([fm createDirectoryAtPath:testDir attributes:nil], nil); +#endif // MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 } else { testDir = baseDir_; } @@ -236,7 +247,17 @@ // create the empty dir NSString *emptyDir = [baseDir_ stringByAppendingPathComponent:@"emptyDir"]; +#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 + NSError *error = nil; + STAssertTrue([fm createDirectoryAtPath:emptyDir + withIntermediateDirectories:YES + attributes:nil + error:&error], + @"Can't create %@ (%@)", emptyDir, error); +#else STAssertTrue([fm createDirectoryAtPath:emptyDir attributes:nil], nil); +#endif // MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 + // single matches = [fm gtm_filePathsWithExtension:@"txt" inDirectory:emptyDir]; -- cgit v1.2.3