Migrate path utilities to C functions instead of encapsulating into static methods on RKDirectory to reduce API size

This commit is contained in:
Blake Watters
2012-08-13 22:53:47 -04:00
parent 975e1674a2
commit 37c70e4c27
12 changed files with 93 additions and 106 deletions

View File

@@ -22,7 +22,7 @@
#import "RKLog.h"
#import "RKPropertyInspector.h"
#import "RKPropertyInspector+CoreData.h"
#import "RKDirectory.h"
#import "RKDirectoryUtilities.h"
#import "RKInMemoryManagedObjectCache.h"
#import "RKFetchRequestManagedObjectCache.h"
#import "NSBundle+RKAdditions.h"
@@ -364,7 +364,7 @@ static RKManagedObjectStore *defaultStore = nil;
+ (void)deleteStoreInApplicationDataDirectoryWithFilename:(NSString *)filename DEPRECATED_ATTRIBUTE
{
NSString *path = [[RKDirectory applicationDataDirectory] stringByAppendingPathComponent:filename];
NSString *path = [RKApplicationDataDirectory() stringByAppendingPathComponent:filename];
[self deleteStoreAtPath:path];
}
@@ -400,8 +400,8 @@ static RKManagedObjectStore *defaultStore = nil;
NSString *storeDirectory = nilOrDirectoryPath;
if (storeDirectory == nil) {
// If initializing into Application Data directory, ensure the directory exists
storeDirectory = [RKDirectory applicationDataDirectory];
[RKDirectory ensureDirectoryExistsAtPath:storeDirectory error:nil];
storeDirectory = RKApplicationDataDirectory();
RKEnsureDirectoryExistsAtPath(storeDirectory, nil);
} else {
// If path given, caller is responsible for directory's existence
BOOL isDir;

View File

@@ -25,7 +25,7 @@
#import "RKLog.h"
#import "RKPathMatcher.h"
#import "NSString+RKAdditions.h"
#import "RKDirectory.h"
#import "RKDirectoryUtilities.h"
// Set Logging Component
#undef RKLogComponent
@@ -224,7 +224,7 @@ dispatch_queue_t rk_get_network_processing_queue(void)
- (NSString *)cachePath
{
NSString *cacheDirForClient = [NSString stringWithFormat:@"RKClientRequestCache-%@", [self.baseURL host]];
NSString *cachePath = [[RKDirectory cachesDirectory]
NSString *cachePath = [RKCachesDirectory()
stringByAppendingPathComponent:cacheDirForClient];
return cachePath;
}

View File

@@ -1,5 +1,5 @@
//
// RKDirectory.h
// RKDirectoryUtilities.h
// RestKit
//
// Created by Blake Watters on 12/9/11.
@@ -8,38 +8,30 @@
#import <Foundation/Foundation.h>
/**
iOS and OS X agnostic accessors for safely returning directory paths for use
by the framework and applications.
*/
@interface RKDirectory : NSObject
/**
Returns the path to the Application Data directory for the executing application. On iOS,
this is a sandboxed path specific for the executing application. On OS X, this is an application
specific path under NSApplicationSupportDirectory (i.e. ~/Application Support).
@return The full path to the application data directory.
*/
+ (NSString *)applicationDataDirectory;
NSString * RKApplicationDataDirectory(void);
/**
Returns a path to the root caches directory used by RestKit for storage. On iOS, this is
a sanboxed path specific for the executing application. On OS X, this is an application
specific path under NSCachesDirectory (i.e. ~/Library/Caches).
@return The full path to the Caches directory.
*/
+ (NSString *)cachesDirectory;
NSString * RKCachesDirectory(void);
/**
Ensures that a directory exists at a given path by checking for the existence
of the directory and creating it if it does not exist.
@param path The path to ensure a directory exists at.
@param error On input, a pointer to an error object.
@returns A Boolean value indicating if the directory exists.
*/
+ (BOOL)ensureDirectoryExistsAtPath:(NSString *)path error:(NSError **)error;
@end
BOOL RKEnsureDirectoryExistsAtPath(NSString *path, NSError **error);

View File

@@ -1,59 +1,56 @@
//
// RKDirectory.m
// RKDirectoryUtilities.m
// RestKit
//
// Created by Blake Watters on 12/9/11.
// Copyright (c) 2009-2012 RestKit. All rights reserved.
//
#import "RKDirectory.h"
#import "RKDirectoryUtilities.h"
#import "NSBundle+RKAdditions.h"
#import "RKLog.h"
@implementation RKDirectory
NSString * RKExecutableName(void);
+ (NSString *)executableName
NSString * RKApplicationDataDirectory(void)
{
#if TARGET_OS_IPHONE
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
return ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
#else
NSFileManager *sharedFM = [NSFileManager defaultManager];
NSArray *possibleURLs = [sharedFM URLsForDirectory:NSApplicationSupportDirectory
inDomains:NSUserDomainMask];
NSURL *appSupportDir = nil;
NSURL *appDirectory = nil;
if ([possibleURLs count] >= 1) {
appSupportDir = [possibleURLs objectAtIndex:0];
}
if (appSupportDir) {
NSString *executableName = [RKDirectory executableName];
appDirectory = [appSupportDir URLByAppendingPathComponent:executableName];
return [appDirectory path];
}
return nil;
#endif
}
NSString * RKExecutableName(void)
{
NSString *executableName = [[[NSBundle mainBundle] executablePath] lastPathComponent];
if (nil == executableName) {
RKLogWarning(@"Unable to determine CFBundleExecutable: storing data under RestKit directory name.");
executableName = @"RestKit";
}
return executableName;
}
+ (NSString *)applicationDataDirectory
{
#if TARGET_OS_IPHONE
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
return ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
#else
NSFileManager *sharedFM = [NSFileManager defaultManager];
NSArray *possibleURLs = [sharedFM URLsForDirectory:NSApplicationSupportDirectory
inDomains:NSUserDomainMask];
NSURL *appSupportDir = nil;
NSURL *appDirectory = nil;
if ([possibleURLs count] >= 1) {
appSupportDir = [possibleURLs objectAtIndex:0];
}
if (appSupportDir) {
NSString *executableName = [RKDirectory executableName];
appDirectory = [appSupportDir URLByAppendingPathComponent:executableName];
return [appDirectory path];
}
return nil;
#endif
}
+ (NSString *)cachesDirectory
NSString * RKCachesDirectory(void)
{
#if TARGET_OS_IPHONE
return [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0];
@@ -63,12 +60,12 @@
if ([paths count]) {
path = [[paths objectAtIndex:0] stringByAppendingPathComponent:[RKDirectory executableName]];
}
return path;
#endif
}
+ (BOOL)ensureDirectoryExistsAtPath:(NSString *)path error:(NSError **)error
BOOL RKEnsureDirectoryExistsAtPath(NSString *path, NSError **error)
{
BOOL isDirectory;
if ([[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:&isDirectory]) {
@@ -78,15 +75,13 @@
return YES;
}
}
// Create the directory and any intermediates
NSError *errorReference = (error == nil) ? nil : *error;
if (! [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:&errorReference]) {
RKLogError(@"Failed to create requested directory at path '%@': %@", path, errorReference);
return NO;
}
return YES;
}
@end

View File

@@ -24,7 +24,7 @@
#import "RKLog.h"
#import "RKPathMatcher.h"
#import "RKDotNetDateFormatter.h"
#import "RKDirectory.h"
#import "RKDirectoryUtilities.h"
#import "RKBenchmark.h"
// Load our categories

View File

@@ -227,7 +227,7 @@ extern NSString * const RKTestFactoryDefaultNamesManagedObjectStore;
Clears the contents of the cache directory by removing the directory and
recreating it.
@see [RKDirectory cachesDirectory]
@see RKCachesDirectory()
*/
+ (void)clearCacheDirectory;

View File

@@ -113,7 +113,7 @@ static RKTestFactory *sharedFactory = nil;
}];
[self defineFactory:RKTestFactoryDefaultNamesManagedObjectStore withBlock:^id {
NSString *storePath = [[RKDirectory applicationDataDirectory] stringByAppendingPathComponent:RKTestFactoryDefaultStoreFilename];
NSString *storePath = [RKApplicationDataDirectory() stringByAppendingPathComponent:RKTestFactoryDefaultStoreFilename];
RKManagedObjectStore *managedObjectStore = [[RKManagedObjectStore alloc] init];
NSError *error;
NSPersistentStore *persistentStore = [managedObjectStore addSQLitePersistentStoreAtPath:storePath fromSeedDatabaseAtPath:nil error:&error];
@@ -216,7 +216,7 @@ static RKTestFactory *sharedFactory = nil;
[RKObjectMapping setDefaultDateFormatters:nil];
// Delete the store if it exists
NSString *path = [[RKDirectory applicationDataDirectory] stringByAppendingPathComponent:RKTestFactoryDefaultStoreFilename];
NSString *path = [RKApplicationDataDirectory() stringByAppendingPathComponent:RKTestFactoryDefaultStoreFilename];
if ([[NSFileManager defaultManager] fileExistsAtPath:path]) {
[[NSFileManager defaultManager] removeItemAtPath:path error:nil];
}
@@ -240,7 +240,7 @@ static RKTestFactory *sharedFactory = nil;
+ (void)clearCacheDirectory
{
NSError *error = nil;
NSString *cachePath = [RKDirectory cachesDirectory];
NSString *cachePath = RKCachesDirectory();
BOOL success = [[NSFileManager defaultManager] removeItemAtPath:cachePath error:&error];
if (success) {
RKLogDebug(@"Cleared cache directory...");

View File

@@ -593,10 +593,10 @@
25AE61DE15ADEF5800B319C8 /* RKConnectionMapping.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BC044C91576CE72003DCDD6 /* RKConnectionMapping.m */; };
25AFF8F115B4CF1F0051877F /* RKMappingErrors.h in Headers */ = {isa = PBXBuildFile; fileRef = 25AFF8F015B4CF1F0051877F /* RKMappingErrors.h */; settings = {ATTRIBUTES = (Public, ); }; };
25AFF8F215B4CF1F0051877F /* RKMappingErrors.h in Headers */ = {isa = PBXBuildFile; fileRef = 25AFF8F015B4CF1F0051877F /* RKMappingErrors.h */; settings = {ATTRIBUTES = (Public, ); }; };
25B408261491CDDC00F21111 /* RKDirectory.h in Headers */ = {isa = PBXBuildFile; fileRef = 25B408241491CDDB00F21111 /* RKDirectory.h */; settings = {ATTRIBUTES = (Public, ); }; };
25B408271491CDDC00F21111 /* RKDirectory.h in Headers */ = {isa = PBXBuildFile; fileRef = 25B408241491CDDB00F21111 /* RKDirectory.h */; settings = {ATTRIBUTES = (Public, ); }; };
25B408281491CDDC00F21111 /* RKDirectory.m in Sources */ = {isa = PBXBuildFile; fileRef = 25B408251491CDDB00F21111 /* RKDirectory.m */; };
25B408291491CDDC00F21111 /* RKDirectory.m in Sources */ = {isa = PBXBuildFile; fileRef = 25B408251491CDDB00F21111 /* RKDirectory.m */; };
25B408261491CDDC00F21111 /* RKDirectoryUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 25B408241491CDDB00F21111 /* RKDirectoryUtilities.h */; settings = {ATTRIBUTES = (Public, ); }; };
25B408271491CDDC00F21111 /* RKDirectoryUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 25B408241491CDDB00F21111 /* RKDirectoryUtilities.h */; settings = {ATTRIBUTES = (Public, ); }; };
25B408281491CDDC00F21111 /* RKDirectoryUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 25B408251491CDDB00F21111 /* RKDirectoryUtilities.m */; };
25B408291491CDDC00F21111 /* RKDirectoryUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 25B408251491CDDB00F21111 /* RKDirectoryUtilities.m */; };
25B6E91E14CF778D00B1E881 /* RKAbstractTableController.h in Headers */ = {isa = PBXBuildFile; fileRef = 25B6E90314CF778D00B1E881 /* RKAbstractTableController.h */; settings = {ATTRIBUTES = (Public, ); }; };
25B6E92014CF778D00B1E881 /* RKAbstractTableController.m in Sources */ = {isa = PBXBuildFile; fileRef = 25B6E90414CF778D00B1E881 /* RKAbstractTableController.m */; };
25B6E92314CF778D00B1E881 /* RKAbstractTableController_Internals.h in Headers */ = {isa = PBXBuildFile; fileRef = 25B6E90614CF778D00B1E881 /* RKAbstractTableController_Internals.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -1145,8 +1145,8 @@
25AE61C415ADE9E500B319C8 /* OCMockObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OCMockObject.h; sourceTree = "<group>"; };
25AE61C515ADE9E500B319C8 /* OCMockRecorder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OCMockRecorder.h; sourceTree = "<group>"; };
25AFF8F015B4CF1F0051877F /* RKMappingErrors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RKMappingErrors.h; sourceTree = "<group>"; };
25B408241491CDDB00F21111 /* RKDirectory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RKDirectory.h; sourceTree = "<group>"; };
25B408251491CDDB00F21111 /* RKDirectory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RKDirectory.m; sourceTree = "<group>"; };
25B408241491CDDB00F21111 /* RKDirectoryUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RKDirectoryUtilities.h; sourceTree = "<group>"; };
25B408251491CDDB00F21111 /* RKDirectoryUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RKDirectoryUtilities.m; sourceTree = "<group>"; };
25B6E90314CF778D00B1E881 /* RKAbstractTableController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RKAbstractTableController.h; sourceTree = "<group>"; };
25B6E90414CF778D00B1E881 /* RKAbstractTableController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RKAbstractTableController.m; sourceTree = "<group>"; };
25B6E90614CF778D00B1E881 /* RKAbstractTableController_Internals.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RKAbstractTableController_Internals.h; sourceTree = "<group>"; };
@@ -1632,8 +1632,8 @@
25160DC6145650490060A5C5 /* RKPathMatcher.h */,
25160DC7145650490060A5C5 /* RKPathMatcher.m */,
25160DCA145650490060A5C5 /* Support.h */,
25B408241491CDDB00F21111 /* RKDirectory.h */,
25B408251491CDDB00F21111 /* RKDirectory.m */,
25B408241491CDDB00F21111 /* RKDirectoryUtilities.h */,
25B408251491CDDB00F21111 /* RKDirectoryUtilities.m */,
250DF22814C5190E0001DEFA /* RKOrderedDictionary.h */,
250DF22914C5190E0001DEFA /* RKOrderedDictionary.m */,
25B6E95414CF795D00B1E881 /* RKErrors.h */,
@@ -2317,7 +2317,7 @@
25160F081456532C0060A5C5 /* SOCKit.h in Headers */,
25160E2E145650490060A5C5 /* RestKit.h in Headers */,
254A62B914AD544200939BEE /* RKObjectPaginator.h in Headers */,
25B408261491CDDC00F21111 /* RKDirectory.h in Headers */,
25B408261491CDDC00F21111 /* RKDirectoryUtilities.h in Headers */,
2513504E14B8FE6B00A7E893 /* RKConfigurationDelegate.h in Headers */,
250DF22A14C5190E0001DEFA /* RKOrderedDictionary.h in Headers */,
49D2759D14C9EF1E0090845D /* ISO8601DateFormatter.h in Headers */,
@@ -2463,7 +2463,7 @@
25160F9C1456576C0060A5C5 /* Support.h in Headers */,
25160F9E1456577F0060A5C5 /* RKJSONParserJSONKit.h in Headers */,
25160F25145655AF0060A5C5 /* RestKit.h in Headers */,
25B408271491CDDC00F21111 /* RKDirectory.h in Headers */,
25B408271491CDDC00F21111 /* RKDirectoryUtilities.h in Headers */,
2513504F14B8FE6B00A7E893 /* RKConfigurationDelegate.h in Headers */,
254A62BA14AD544200939BEE /* RKObjectPaginator.h in Headers */,
250DF22B14C5190E0001DEFA /* RKOrderedDictionary.h in Headers */,
@@ -2868,7 +2868,7 @@
25160EE41456532C0060A5C5 /* lcl.m in Sources */,
25160EFA1456532C0060A5C5 /* LCLNSLog.m in Sources */,
25160F0A1456532C0060A5C5 /* SOCKit.m in Sources */,
25B408281491CDDC00F21111 /* RKDirectory.m in Sources */,
25B408281491CDDC00F21111 /* RKDirectoryUtilities.m in Sources */,
254A62BB14AD544200939BEE /* RKObjectPaginator.m in Sources */,
250DF22C14C5190E0001DEFA /* RKOrderedDictionary.m in Sources */,
49D2759F14C9EF1E0090845D /* ISO8601DateFormatter.m in Sources */,
@@ -3082,7 +3082,7 @@
25160F961456576C0060A5C5 /* RKMIMETypes.m in Sources */,
25160F991456576C0060A5C5 /* RKPathMatcher.m in Sources */,
25160F9F1456577F0060A5C5 /* RKJSONParserJSONKit.m in Sources */,
25B408291491CDDC00F21111 /* RKDirectory.m in Sources */,
25B408291491CDDC00F21111 /* RKDirectoryUtilities.m in Sources */,
254A62BC14AD544200939BEE /* RKObjectPaginator.m in Sources */,
250DF22D14C5190E0001DEFA /* RKOrderedDictionary.m in Sources */,
49D275A114C9EF1E0090845D /* ISO8601DateFormatter.m in Sources */,

View File

@@ -20,7 +20,7 @@
#import "RKTestEnvironment.h"
#import "RKHuman.h"
#import "RKDirectory.h"
#import "RKDirectoryUtilities.h"
@interface RKManagedObjectStoreTest : RKTestCase
@@ -34,10 +34,10 @@
// Delete any sqlite files in the app data directory
NSError *error;
NSArray *paths = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:[RKDirectory applicationDataDirectory] error:&error];
NSArray *paths = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:RKApplicationDataDirectory() error:&error];
for (NSString *path in paths) {
if ([[path pathExtension] isEqualToString:@"sqlite"]) {
NSString *fullPath = [[RKDirectory applicationDataDirectory] stringByAppendingPathComponent:path];
NSString *fullPath = [RKApplicationDataDirectory() stringByAppendingPathComponent:path];
BOOL success = [[NSFileManager defaultManager] removeItemAtPath:fullPath error:&error];
NSAssert(success, @"Failed to remove SQLite file at path: %@", fullPath);
}
@@ -60,7 +60,7 @@
{
// Create a store with a SQLite database to use as our store
RKManagedObjectStore *seedStore = [[RKManagedObjectStore alloc] init];
NSString *seedPath = [[RKDirectory applicationDataDirectory] stringByAppendingPathComponent:@"Seed.sqlite"];
NSString *seedPath = [RKApplicationDataDirectory() stringByAppendingPathComponent:@"Seed.sqlite"];
NSError *error;
NSPersistentStore *persistentStore = [seedStore addSQLitePersistentStoreAtPath:seedPath fromSeedDatabaseAtPath:nil error:&error];
assertThat(persistentStore, is(notNilValue()));
@@ -70,7 +70,7 @@
// Create a secondary store using the seed
RKManagedObjectStore *managedObjectStore = [[RKManagedObjectStore alloc] init];
NSString *storePath = [[RKDirectory applicationDataDirectory] stringByAppendingPathComponent:@"Test.sqlite"];
NSString *storePath = [RKApplicationDataDirectory() stringByAppendingPathComponent:@"Test.sqlite"];
persistentStore = [managedObjectStore addSQLitePersistentStoreAtPath:storePath fromSeedDatabaseAtPath:seedPath error:&error];
assertThat(persistentStore, is(notNilValue()));
@@ -88,7 +88,7 @@
// Create a store with an object to serve as our seed database
RKManagedObjectStore *seedStore = [[RKManagedObjectStore alloc] init];
NSError *error;
NSString *seedPath = [[RKDirectory applicationDataDirectory] stringByAppendingPathComponent:@"Seed.sqlite"];
NSString *seedPath = [RKApplicationDataDirectory() stringByAppendingPathComponent:@"Seed.sqlite"];
NSPersistentStore *seedPersistentStore = [seedStore addSQLitePersistentStoreAtPath:seedPath fromSeedDatabaseAtPath:nil error:&error];
assertThat(seedPersistentStore, is(notNilValue()));
[seedStore createManagedObjectContexts];
@@ -100,7 +100,7 @@
[seedStore release];
// Create a secondary store using the first store as the seed
NSString *storePath = [[RKDirectory applicationDataDirectory] stringByAppendingPathComponent:@"SeededStore.sqlite"];
NSString *storePath = [RKApplicationDataDirectory() stringByAppendingPathComponent:@"SeededStore.sqlite"];
RKManagedObjectStore *seededStore = [[RKManagedObjectStore alloc] init];
NSPersistentStore *persistentStore = [seededStore addSQLitePersistentStoreAtPath:storePath fromSeedDatabaseAtPath:seedPath error:&error];
assertThat(persistentStore, is(notNilValue()));
@@ -150,7 +150,7 @@
{
RKManagedObjectStore *managedObjectStore = [[RKManagedObjectStore alloc] init];
NSError *error;
NSString *storePath = [[RKDirectory applicationDataDirectory] stringByAppendingPathComponent:@"Test.sqlite"];
NSString *storePath = [RKApplicationDataDirectory() stringByAppendingPathComponent:@"Test.sqlite"];
NSPersistentStore *persistentStore = [managedObjectStore addSQLitePersistentStoreAtPath:storePath fromSeedDatabaseAtPath:nil error:&error];
assertThat(persistentStore, is(notNilValue()));
[managedObjectStore createManagedObjectContexts];
@@ -178,7 +178,7 @@
{
RKManagedObjectStore *managedObjectStore = [[RKManagedObjectStore alloc] init];
NSError *error;
NSString *storePath = [[RKDirectory applicationDataDirectory] stringByAppendingPathComponent:@"Test.sqlite"];
NSString *storePath = [RKApplicationDataDirectory() stringByAppendingPathComponent:@"Test.sqlite"];
NSPersistentStore *persistentStore = [managedObjectStore addSQLitePersistentStoreAtPath:storePath fromSeedDatabaseAtPath:nil error:&error];
assertThat(persistentStore, is(notNilValue()));
[managedObjectStore createManagedObjectContexts];
@@ -208,7 +208,7 @@
// Create a store with an object to serve as our seed database
RKManagedObjectStore *seedStore = [[RKManagedObjectStore alloc] init];
NSError *error;
NSString *seedPath = [[RKDirectory applicationDataDirectory] stringByAppendingPathComponent:@"Seed.sqlite"];
NSString *seedPath = [RKApplicationDataDirectory() stringByAppendingPathComponent:@"Seed.sqlite"];
NSPersistentStore *seedPersistentStore = [seedStore addSQLitePersistentStoreAtPath:seedPath fromSeedDatabaseAtPath:nil error:&error];
assertThat(seedPersistentStore, is(notNilValue()));
[seedStore createManagedObjectContexts];
@@ -220,7 +220,7 @@
[seedStore release];
// Create a secondary store using the first store as the seed
NSString *storePath = [[RKDirectory applicationDataDirectory] stringByAppendingPathComponent:@"SeededStore.sqlite"];
NSString *storePath = [RKApplicationDataDirectory() stringByAppendingPathComponent:@"SeededStore.sqlite"];
RKManagedObjectStore *seededStore = [[RKManagedObjectStore alloc] init];
NSPersistentStore *persistentStore = [seededStore addSQLitePersistentStoreAtPath:storePath fromSeedDatabaseAtPath:seedPath error:&error];
assertThat(persistentStore, is(notNilValue()));

View File

@@ -23,7 +23,7 @@
#import "RKParams.h"
#import "RKResponse.h"
#import "RKURL.h"
#import "RKDirectory.h"
#import "RKDirectoryUtilities.h"
@interface RKRequest (Private)
- (void)fireAsynchronousRequest;
@@ -349,7 +349,7 @@ request.timeoutInterval = 1.0;
NSString *baseURL = [RKTestFactory baseURLString];
NSString *cacheDirForClient = [NSString stringWithFormat:@"RKClientRequestCache-%@",
[[NSURL URLWithString:baseURL] host]];
NSString *cachePath = [[RKDirectory cachesDirectory]
NSString *cachePath = [RKCachesDirectory()
stringByAppendingPathComponent:cacheDirForClient];
RKRequestCache *cache = [[RKRequestCache alloc] initWithPath:cachePath
storagePolicy:RKRequestCacheStoragePolicyPermanently];
@@ -376,7 +376,7 @@ request.timeoutInterval = 1.0;
NSString *baseURL = [RKTestFactory baseURLString];
NSString *cacheDirForClient = [NSString stringWithFormat:@"RKClientRequestCache-%@",
[[NSURL URLWithString:baseURL] host]];
NSString *cachePath = [[RKDirectory cachesDirectory]
NSString *cachePath = [RKCachesDirectory()
stringByAppendingPathComponent:cacheDirForClient];
RKRequestCache *cache = [[RKRequestCache alloc] initWithPath:cachePath
storagePolicy:RKRequestCacheStoragePolicyPermanently];
@@ -402,7 +402,7 @@ request.timeoutInterval = 1.0;
NSString *baseURL = [RKTestFactory baseURLString];
NSString *cacheDirForClient = [NSString stringWithFormat:@"RKClientRequestCache-%@",
[[NSURL URLWithString:baseURL] host]];
NSString *cachePath = [[RKDirectory cachesDirectory]
NSString *cachePath = [RKCachesDirectory()
stringByAppendingPathComponent:cacheDirForClient];
RKRequestCache *cache = [[RKRequestCache alloc] initWithPath:cachePath
storagePolicy:RKRequestCacheStoragePolicyPermanently];
@@ -443,7 +443,7 @@ request.timeoutInterval = 1.0;
NSString *baseURL = [RKTestFactory baseURLString];
NSString *cacheDirForClient = [NSString stringWithFormat:@"RKClientRequestCache-%@",
[[NSURL URLWithString:baseURL] host]];
NSString *cachePath = [[RKDirectory cachesDirectory]
NSString *cachePath = [RKCachesDirectory()
stringByAppendingPathComponent:cacheDirForClient];
RKRequestCache *cache = [[RKRequestCache alloc] initWithPath:cachePath
storagePolicy:RKRequestCacheStoragePolicyPermanently];
@@ -491,7 +491,7 @@ request.timeoutInterval = 1.0;
NSString *baseURL = [RKTestFactory baseURLString];
NSString *cacheDirForClient = [NSString stringWithFormat:@"RKClientRequestCache-%@",
[[NSURL URLWithString:baseURL] host]];
NSString *cachePath = [[RKDirectory cachesDirectory]
NSString *cachePath = [RKCachesDirectory()
stringByAppendingPathComponent:cacheDirForClient];
RKRequestCache *cache = [[RKRequestCache alloc] initWithPath:cachePath
storagePolicy:RKRequestCacheStoragePolicyPermanently];
@@ -530,7 +530,7 @@ request.timeoutInterval = 1.0;
NSString *baseURL = [RKTestFactory baseURLString];
NSString *cacheDirForClient = [NSString stringWithFormat:@"RKClientRequestCache-%@",
[[NSURL URLWithString:baseURL] host]];
NSString *cachePath = [[RKDirectory cachesDirectory]
NSString *cachePath = [RKCachesDirectory()
stringByAppendingPathComponent:cacheDirForClient];
RKRequestCache *cache = [[RKRequestCache alloc] initWithPath:cachePath
storagePolicy:RKRequestCacheStoragePolicyPermanently];
@@ -595,7 +595,7 @@ request.timeoutInterval = 1.0;
NSString *baseURL = [RKTestFactory baseURLString];
NSString *cacheDirForClient = [NSString stringWithFormat:@"RKClientRequestCache-%@",
[[NSURL URLWithString:baseURL] host]];
NSString *cachePath = [[RKDirectory cachesDirectory]
NSString *cachePath = [RKCachesDirectory()
stringByAppendingPathComponent:cacheDirForClient];
RKRequestCache *cache = [[RKRequestCache alloc] initWithPath:cachePath
storagePolicy:RKRequestCacheStoragePolicyPermanently];
@@ -639,7 +639,7 @@ request.timeoutInterval = 1.0;
NSString *baseURL = [RKTestFactory baseURLString];
NSString *cacheDirForClient = [NSString stringWithFormat:@"RKClientRequestCache-%@",
[[NSURL URLWithString:baseURL] host]];
NSString *cachePath = [[RKDirectory cachesDirectory]
NSString *cachePath = [RKCachesDirectory()
stringByAppendingPathComponent:cacheDirForClient];
RKRequestCache *cache = [[RKRequestCache alloc] initWithPath:cachePath
@@ -840,7 +840,7 @@ request.timeoutInterval = 1.0;
NSString *baseURL = [RKTestFactory baseURLString];
NSString *cacheDirForClient = [NSString stringWithFormat:@"RKClientRequestCache-%@",
[[NSURL URLWithString:baseURL] host]];
NSString *cachePath = [[RKDirectory cachesDirectory]
NSString *cachePath = [RKCachesDirectory()
stringByAppendingPathComponent:cacheDirForClient];
RKRequestCache *requestCache = [[RKRequestCache alloc] initWithPath:cachePath storagePolicy:RKRequestCacheStoragePolicyForDurationOfSession];
NSString *requestCachePath = [requestCache pathForRequest:request];
@@ -859,7 +859,7 @@ request.timeoutInterval = 1.0;
NSString *baseURL = [RKTestFactory baseURLString];
NSString *cacheDirForClient = [NSString stringWithFormat:@"RKClientRequestCache-%@",
[[NSURL URLWithString:baseURL] host]];
NSString *cachePath = [[RKDirectory cachesDirectory]
NSString *cachePath = [RKCachesDirectory()
stringByAppendingPathComponent:cacheDirForClient];
RKRequestCache *requestCache = [[RKRequestCache alloc] initWithPath:cachePath storagePolicy:RKRequestCacheStoragePolicyForDurationOfSession];
NSString *requestCachePath = [requestCache pathForRequest:request];

View File

@@ -7,7 +7,7 @@
//
#import "RKTestEnvironment.h"
#import "RKDirectory.h"
#import "RKDirectoryUtilities.h"
@interface RKCacheTest : RKTestCase
@@ -17,7 +17,7 @@
- (void)testCreationOfIntermediateDirectories
{
NSString *cachePath = [RKDirectory cachesDirectory];
NSString *cachePath = RKCachesDirectory();
NSString *subPath = [cachePath stringByAppendingPathComponent:@"TestPath"];
NSError *error = nil;
[[NSFileManager defaultManager] removeItemAtPath:cachePath error:&error];

View File

@@ -43,13 +43,13 @@ RKOAuthClient *RKTestNewOAuthClient(RKTestResponseLoader *loader)
// Ensure the required directories exist
BOOL directoryExists;
NSError *error = nil;
directoryExists = [RKDirectory ensureDirectoryExistsAtPath:[RKDirectory applicationDataDirectory] error:&error];
directoryExists = RKEnsureDirectoryExistsAtPath(RKApplicationDataDirectory(), &error);
if (! directoryExists) {
RKLogError(@"Failed to create application data directory. Unable to run tests: %@", error);
NSAssert(directoryExists, @"Failed to create application data directory.");
}
directoryExists = [RKDirectory ensureDirectoryExistsAtPath:[RKDirectory cachesDirectory] error:&error];
directoryExists = RKEnsureDirectoryExistsAtPath(RKCachesDirectory(), &error);
if (! directoryExists) {
RKLogError(@"Failed to create caches directory. Unable to run tests: %@", error);
NSAssert(directoryExists, @"Failed to create caches directory.");