aboutsummaryrefslogtreecommitdiff
path: root/Foundation/GTMNSFileManager+PathTest.m
diff options
context:
space:
mode:
authorGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2010-05-14 19:35:54 +0000
committerGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2010-05-14 19:35:54 +0000
commit4f89cfe836e82f9445b98d733d6eb54b86e609d2 (patch)
treedd5f8eb01940af1a98922254baa93437936dc2ed /Foundation/GTMNSFileManager+PathTest.m
parent4e865a397220fcca9975de0ed393ed7a145234d2 (diff)
[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)
Diffstat (limited to 'Foundation/GTMNSFileManager+PathTest.m')
-rw-r--r--Foundation/GTMNSFileManager+PathTest.m51
1 files changed, 36 insertions, 15 deletions
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];