Removed dir enums, updated readme
This commit is contained in:
parent
00d312ed3f
commit
354a218573
|
@ -21,3 +21,4 @@ DerivedData
|
|||
.idea/
|
||||
# Pods - for those of you who use CocoaPods
|
||||
Pods
|
||||
update-test.sh
|
||||
|
|
|
@ -134,9 +134,7 @@ var RNFS = {
|
|||
.catch(convertError);
|
||||
},
|
||||
|
||||
MainBundle: RNFSManager.MainBundleDirectory,
|
||||
CachesDirectory: RNFSManager.NSCachesDirectory,
|
||||
DocumentDirectory: RNFSManager.NSDocumentDirectory,
|
||||
MainBundlePath: RNFSManager.MainBundlePath,
|
||||
CachesDirectoryPath: RNFSManager.NSCachesDirectoryPath,
|
||||
DocumentDirectoryPath: RNFSManager.NSDocumentDirectoryPath
|
||||
};
|
||||
|
|
11
README.md
11
README.md
|
@ -89,7 +89,7 @@ public class MainActivity extends Activity implements DefaultHardwareBackBtnHand
|
|||
var RNFS = require('react-native-fs');
|
||||
|
||||
// get a list of files and directories in the main bundle
|
||||
RNFS.readDir('/', RNFS.MainBundle)
|
||||
RNFS.readDir(RNFS.MainBundlePath)
|
||||
.then((result) => {
|
||||
console.log('GOT RESULT', result);
|
||||
|
||||
|
@ -157,11 +157,8 @@ return RNFS.unlink(path)
|
|||
|
||||
The following constants are available on the `RNFS` export:
|
||||
|
||||
`MainBundle` (`Number`) The identifier for the main bundle
|
||||
`CachesDirectory` (`Number`) The identifier for the caches directory
|
||||
`DocumentDirectory` (`Number`) The identifier for the document directory
|
||||
|
||||
`CachesDirectoryPath` (`String`) The absolute path to the caches directory
|
||||
`MainBundlePath` (`String`) The absolute path to the main bundle directory
|
||||
`CachesDirectoryPath` (`String`) The absolute path to the caches directory
|
||||
`DocumentDirectoryPath` (`String`) The absolute path to the document directory
|
||||
|
||||
### `promise readDir(path)`
|
||||
|
@ -171,7 +168,7 @@ Reads the contents of `path`. This must be an absolute path. Use the above path
|
|||
The returned promise resolves with an array of objects with the following properties:
|
||||
|
||||
`name` (`String`), The name of the item
|
||||
`path` (`String`), The absolute path to the item
|
||||
`path` (`String`), The absolute path to the item
|
||||
`size` (`Number`), Size in bytes
|
||||
|
||||
### `promise readdir(path)`
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
|
||||
@implementation RNFSManager
|
||||
|
||||
static int MainBundleDirectory = 999;
|
||||
|
||||
RCT_EXPORT_MODULE();
|
||||
|
||||
- (dispatch_queue_t)methodQueue
|
||||
|
@ -144,13 +142,19 @@ RCT_EXPORT_METHOD(downloadFile:(NSString *)urlStr
|
|||
filepath:(NSString *)filepath
|
||||
callback:(RCTResponseSenderBlock)callback)
|
||||
{
|
||||
NSError *error = nil;
|
||||
|
||||
NSURL *url = [NSURL URLWithString:urlStr];
|
||||
NSData *urlData = [NSData dataWithContentsOfURL:url];
|
||||
NSData *urlData = [NSData dataWithContentsOfURL:url options:NSDataReadingUncached error:&error];
|
||||
|
||||
BOOL success = NO;
|
||||
if (error) {
|
||||
return callback([self makeErrorPayload:error]);
|
||||
}
|
||||
|
||||
if (urlData) {
|
||||
success = [urlData writeToFile:filepath atomically:YES];
|
||||
BOOL success = [urlData writeToFile:filepath atomically:YES];
|
||||
|
||||
if (!success) {
|
||||
return callback(@[[NSString stringWithFormat:@"Could not write downloaded data to file at path %@", filepath]]);
|
||||
}
|
||||
|
||||
callback(@[[NSNull null], [NSNumber numberWithBool:success], filepath]);
|
||||
|
@ -203,11 +207,9 @@ RCT_EXPORT_METHOD(pathForBundle:(NSString *)bundleNamed
|
|||
- (NSDictionary *)constantsToExport
|
||||
{
|
||||
return @{
|
||||
@"MainBundlePath": [[NSBundle mainBundle] bundlePath],
|
||||
@"NSCachesDirectoryPath": [self getPathForDirectory:NSCachesDirectory],
|
||||
@"NSDocumentDirectoryPath": [self getPathForDirectory:NSDocumentDirectory],
|
||||
@"NSCachesDirectory": [NSNumber numberWithInteger:NSCachesDirectory],
|
||||
@"NSDocumentDirectory": [NSNumber numberWithInteger:NSDocumentDirectory],
|
||||
@"MainBundleDirectory": [NSNumber numberWithInteger:MainBundleDirectory],
|
||||
@"NSFileTypeRegular": NSFileTypeRegular,
|
||||
@"NSFileTypeDirectory": NSFileTypeDirectory
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue