File tree 3 files changed +9
-7
lines changed
3 files changed +9
-7
lines changed Original file line number Diff line number Diff line change 8
8
9
9
@interface NSArray (Map)
10
10
11
- - (NSArray *)mapObjectsUsingBlock : (id (^)(id obj, NSUInteger idx))block ;
11
+ - (NSArray *)rnfs_mapObjectsUsingBlock : (id (^)(id obj, NSUInteger idx))block ;
12
12
13
13
@end
Original file line number Diff line number Diff line change 6
6
7
7
@implementation NSArray (Map)
8
8
9
- - (NSArray *)mapObjectsUsingBlock : (id (^)(id obj, NSUInteger idx))block {
9
+ - (NSArray *)rnfs_mapObjectsUsingBlock : (id (^)(id obj, NSUInteger idx))block {
10
10
NSMutableArray *result = [NSMutableArray arrayWithCapacity: [self count ]];
11
11
[self enumerateObjectsUsingBlock: ^(id obj, NSUInteger idx, BOOL *stop) {
12
12
[result addObject: block (obj, idx)];
Original file line number Diff line number Diff line change 7
7
//
8
8
9
9
#import " RNFSManager.h"
10
- #import " RCTConvert.h"
11
10
#import " RCTBridge.h"
12
11
#import " NSArray+Map.h"
13
12
@@ -18,6 +17,9 @@ @implementation RNFSManager
18
17
@synthesize bridge = _bridge;
19
18
RCT_EXPORT_MODULE ();
20
19
20
+ - (dispatch_queue_t )methodQueue {
21
+ return dispatch_queue_create (" pe.lum.rnfs" , DISPATCH_QUEUE_SERIAL);
22
+ }
21
23
22
24
RCT_EXPORT_METHOD (readDir:(NSString *)directory inFolder:(NSNumber *)folder callback:(RCTResponseSenderBlock)callback){
23
25
NSString *path;
@@ -31,11 +33,11 @@ @implementation RNFSManager
31
33
}
32
34
33
35
NSFileManager *fileManager = [NSFileManager defaultManager ];
34
- NSError *error;
36
+ NSError *error = nil ;
35
37
NSString * dirPath = [path stringByAppendingPathComponent: directory];
36
38
NSArray *contents = [fileManager contentsOfDirectoryAtPath: dirPath error: &error];
37
39
38
- contents = [contents mapObjectsUsingBlock : ^id (id obj, NSUInteger idx) {
40
+ contents = [contents rnfs_mapObjectsUsingBlock : ^id (id obj, NSUInteger idx) {
39
41
return @{
40
42
@" name" : (NSString *)obj,
41
43
@" path" : [dirPath stringByAppendingPathComponent: (NSString *)obj]
@@ -50,7 +52,7 @@ @implementation RNFSManager
50
52
}
51
53
52
54
RCT_EXPORT_METHOD (stat:(NSString *)filepath callback:(RCTResponseSenderBlock)callback){
53
- NSError *error;
55
+ NSError *error = nil ;
54
56
NSDictionary *attributes = [[NSFileManager defaultManager ] attributesOfItemAtPath: filepath error: &error];
55
57
56
58
if (error) {
@@ -86,7 +88,7 @@ @implementation RNFSManager
86
88
if (!exists) {
87
89
return callback (@[[NSString stringWithFormat: @" File at path %@ does not exist" , filepath]]);
88
90
}
89
- NSError *error;
91
+ NSError *error = nil ;
90
92
BOOL success = [manager removeItemAtPath: filepath error: &error];
91
93
92
94
if (!success) {
You can’t perform that action at this time.
0 commit comments