15
15
#import " ReactNativeBlobUtilSpec.h"
16
16
#endif
17
17
18
-
19
18
__strong RCTEventDispatcher * eventDispatcherRef;
20
19
dispatch_queue_t commonTaskQueue;
21
20
dispatch_queue_t fsQueue;
@@ -67,11 +66,11 @@ - (id) init {
67
66
if (![[NSFileManager defaultManager ] fileExistsAtPath: [ReactNativeBlobUtilFS getTempPath ] isDirectory: &isDir]) {
68
67
[[NSFileManager defaultManager ] createDirectoryAtPath: [ReactNativeBlobUtilFS getTempPath ] withIntermediateDirectories: YES attributes: nil error: NULL ];
69
68
}
70
- eventDispatcherRef = nil ;
71
69
dispatch_async (dispatch_get_main_queue (), ^{
72
70
eventDispatcherRef = [ReactNativeBlobUtil getRCTEventDispatcher ];
73
71
[ReactNativeBlobUtilNetwork emitExpiredTasks: eventDispatcherRef];
74
72
});
73
+
75
74
return self;
76
75
}
77
76
@@ -412,7 +411,6 @@ - (void)writeFileArray:(NSString *)path
412
411
RCT_EXPORT_METHOD (unlink:(NSString *)path callback:(RCTResponseSenderBlock) callback)
413
412
{
414
413
NSError * error = nil ;
415
- NSString * tmpPath = nil ;
416
414
[[NSFileManager defaultManager ] removeItemAtPath: path error: &error];
417
415
if (error == nil || [[NSFileManager defaultManager ] fileExistsAtPath: path] == NO )
418
416
callback (@[[NSNull null ]]);
@@ -424,7 +422,6 @@ - (void)writeFileArray:(NSString *)path
424
422
RCT_EXPORT_METHOD (removeSession:(NSArray *)paths callback:(RCTResponseSenderBlock) callback)
425
423
{
426
424
NSError * error = nil ;
427
- NSString * tmpPath = nil ;
428
425
429
426
for (NSString * path in paths) {
430
427
[[NSFileManager defaultManager ] removeItemAtPath: path error: &error];
@@ -487,7 +484,7 @@ - (void)ls:(NSString *)path
487
484
callback (@[[NSString stringWithFormat: @" failed to stat path `%@ ` because it does not exist or it is not a folder" , path]]);
488
485
return ;
489
486
}
490
- result = [ReactNativeBlobUtilFS stat: path error: &error];
487
+ result = [ReactNativeBlobUtilFS stat: path error: &error]. mutableCopy ;
491
488
492
489
if (error == nil )
493
490
callback (@[[NSNull null ], result]);
@@ -639,11 +636,13 @@ - (void)readFile:(NSString *)path
639
636
reject (code, err, nil );
640
637
return ;
641
638
}
642
- if (encoding == @" ascii" ) {
639
+ if ([ encoding isEqualToString: @" ascii" ] ) {
643
640
resolve ((NSMutableArray *)content);
644
641
}
645
- else {
646
- resolve ((NSString *)content);
642
+ if ([encoding isEqualToString: @" base64" ]) {
643
+ resolve ([content base64EncodedStringWithOptions: 0 ]);
644
+ } else {
645
+ resolve ([[NSString alloc ] initWithData: content encoding: NSUTF8StringEncoding]);
647
646
}
648
647
}];
649
648
}
@@ -869,6 +868,11 @@ - (UIViewController *) documentInteractionControllerViewControllerForPreview: (U
869
868
870
869
871
870
#if RCT_NEW_ARCH_ENABLED
871
+ - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule :
872
+ (const facebook::react::ObjCTurboModule::InitParams &)params
873
+ {
874
+ return std::make_shared<facebook::react::NativeBlobUtilsSpecJSI>(params);
875
+ }
872
876
#endif
873
877
874
878
@end
0 commit comments