Added Cache and Document directory paths as constants

This commit is contained in:
Johannes Lumpe 2015-05-08 20:17:59 +03:00
parent 1821893891
commit 78f5272521
2 changed files with 10 additions and 1 deletions

View File

@ -52,7 +52,9 @@ var RNFS = {
MainBundle: RNFSManager.MainBundleDirectory,
CachesDirectory: RNFSManager.NSCachesDirectory,
DocumentDirectory: RNFSManager.NSDocumentDirectory
DocumentDirectory: RNFSManager.NSDocumentDirectory,
CachesDirectoryPath: RNFSManager.NSCachesDirectoryPath,
DocumentDirectoryPath: RNFSManager.NSDocumentDirectoryPath
};
module.exports = RNFS;

View File

@ -91,9 +91,16 @@ RCT_EXPORT_METHOD(readFile:(NSString*)filepath callback:(RCTResponseSenderBlock)
}];
}
- (NSString*) getPathForDirectory:(int)directory {
NSArray *paths = NSSearchPathForDirectoriesInDomains(directory, NSUserDomainMask, YES);
return [paths objectAtIndex:0];
}
- (NSDictionary *)constantsToExport
{
return @{
@"NSCachesDirectoryPath": [self getPathForDirectory:NSCachesDirectory],
@"NSDocumentDirectoryPath": [self getPathForDirectory:NSDocumentDirectory],
@"NSCachesDirectory": [NSNumber numberWithInteger:NSCachesDirectory],
@"NSDocumentDirectory": [NSNumber numberWithInteger:NSDocumentDirectory],
@"MainBundleDirectory": [NSNumber numberWithInteger:MainBundleDirectory],