1515#import " ReactNativeBlobUtilSpec.h"
1616#endif
1717
18-
1918__strong RCTEventDispatcher * eventDispatcherRef;
2019dispatch_queue_t commonTaskQueue;
2120dispatch_queue_t fsQueue;
@@ -67,11 +66,11 @@ - (id) init {
6766 if (![[NSFileManager defaultManager ] fileExistsAtPath: [ReactNativeBlobUtilFS getTempPath ] isDirectory: &isDir]) {
6867 [[NSFileManager defaultManager ] createDirectoryAtPath: [ReactNativeBlobUtilFS getTempPath ] withIntermediateDirectories: YES attributes: nil error: NULL ];
6968 }
70- eventDispatcherRef = nil ;
7169 dispatch_async (dispatch_get_main_queue (), ^{
7270 eventDispatcherRef = [ReactNativeBlobUtil getRCTEventDispatcher ];
7371 [ReactNativeBlobUtilNetwork emitExpiredTasks: eventDispatcherRef];
7472 });
73+
7574 return self;
7675}
7776
@@ -412,7 +411,6 @@ - (void)writeFileArray:(NSString *)path
412411RCT_EXPORT_METHOD (unlink:(NSString *)path callback:(RCTResponseSenderBlock) callback)
413412{
414413 NSError * error = nil ;
415- NSString * tmpPath = nil ;
416414 [[NSFileManager defaultManager ] removeItemAtPath: path error: &error];
417415 if (error == nil || [[NSFileManager defaultManager ] fileExistsAtPath: path] == NO )
418416 callback (@[[NSNull null ]]);
@@ -424,7 +422,6 @@ - (void)writeFileArray:(NSString *)path
424422RCT_EXPORT_METHOD (removeSession:(NSArray *)paths callback:(RCTResponseSenderBlock) callback)
425423{
426424 NSError * error = nil ;
427- NSString * tmpPath = nil ;
428425
429426 for (NSString * path in paths) {
430427 [[NSFileManager defaultManager ] removeItemAtPath: path error: &error];
@@ -487,7 +484,7 @@ - (void)ls:(NSString *)path
487484 callback (@[[NSString stringWithFormat: @" failed to stat path `%@ ` because it does not exist or it is not a folder" , path]]);
488485 return ;
489486 }
490- result = [ReactNativeBlobUtilFS stat: path error: &error];
487+ result = [ReactNativeBlobUtilFS stat: path error: &error]. mutableCopy ;
491488
492489 if (error == nil )
493490 callback (@[[NSNull null ], result]);
@@ -639,11 +636,13 @@ - (void)readFile:(NSString *)path
639636 reject (code, err, nil );
640637 return ;
641638 }
642- if (encoding == @" ascii" ) {
639+ if ([ encoding isEqualToString: @" ascii" ] ) {
643640 resolve ((NSMutableArray *)content);
644641 }
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]);
647646 }
648647 }];
649648}
@@ -869,6 +868,11 @@ - (UIViewController *) documentInteractionControllerViewControllerForPreview: (U
869868
870869
871870#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+ }
872876#endif
873877
874878@end
0 commit comments