Skip to content

Commit

Permalink
Merge branch 'dev-2.21'
Browse files Browse the repository at this point in the history
  • Loading branch information
birdofpreyru committed Aug 7, 2023
2 parents a202fb7 + 128c892 commit affe286
Show file tree
Hide file tree
Showing 9 changed files with 175 additions and 56 deletions.
2 changes: 1 addition & 1 deletion example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ target 'ReactNativeFsExample' do
react_native_post_install(
installer,
config[:reactNativePath],
:mac_catalyst_enabled => false
:mac_catalyst_enabled => ENV['MAC_CATALYST'] == '1'
)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
end
Expand Down
6 changes: 3 additions & 3 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PODS:
- boost (1.76.0)
- CocoaAsyncSocket (7.6.5)
- DoubleConversion (1.1.6)
- dr-pogodin-react-native-fs (2.21.0-alpha.1):
- dr-pogodin-react-native-fs (2.21.0-alpha.2):
- hermes-engine
- RCT-Folly (= 2021.07.22.00)
- RCTRequired
Expand Down Expand Up @@ -1259,7 +1259,7 @@ SPEC CHECKSUMS:
boost: 57d2868c099736d80fcd648bf211b4431e51a558
CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99
DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54
dr-pogodin-react-native-fs: bbb9988de39ebd12dde9c3d05c210002ca3eb57c
dr-pogodin-react-native-fs: 2ea0bcb4cc87ad09f8929476acf38cdea5f5e75a
FBLazyVector: 4cce221dd782d3ff7c4172167bba09d58af67ccb
Flipper: 6edb735e6c3e332975d1b17956bcc584eccf5818
Flipper-Boost-iOSX: fd1e2b8cbef7e662a122412d7ac5f5bea715403c
Expand Down Expand Up @@ -1314,6 +1314,6 @@ SPEC CHECKSUMS:
Yoga: 8796b55dba14d7004f980b54bcc9833ee45b28ce
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a

PODFILE CHECKSUM: 590fe0a5893c85a8f75660561157ee1d2cee82db
PODFILE CHECKSUM: 37e3e3cd5f6e9261215fe1830262c52d2266ce15

COCOAPODS: 1.12.1
12 changes: 6 additions & 6 deletions ios/RNException.h → ios/RNFSException.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#import <React/RCTBridgeModule.h>

@interface RNException : NSException
@interface RNFSException : NSException
- (id) initWithName: (NSString*)name details: (NSString*)details;
- (NSError*) error;
- (RNException*) log;
- (RNFSException*) log;
- (void) reject:(RCTPromiseRejectBlock)reject;
- (void) reject:(RCTPromiseRejectBlock)reject details:(NSString*)details;
+ (RNException*) from: (NSException*)exception;
+ (RNException*) name: (NSString*)name;
+ (RNException*) name: (NSString*)name details: (NSString*)details;
+ (RNFSException*) from: (NSException*)exception;
+ (RNFSException*) name: (NSString*)name;
+ (RNFSException*) name: (NSString*)name details: (NSString*)details;

+ (RNException*) NOT_IMPLEMENTED;
+ (RNFSException*) NOT_IMPLEMENTED;

@property(readonly) NSInteger code;
@end
24 changes: 12 additions & 12 deletions ios/RNException.mm → ios/RNFSException.mm
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#import "RNException.h"
#import "RNFSException.h"

static NSString * const ERROR_DOMAIN = @"RNFS";

@implementation RNException;
@implementation RNFSException;

- (id) initWithName:(NSString*)name details:(NSString*)details
{
Expand All @@ -11,7 +11,7 @@ - (id) initWithName:(NSString*)name details:(NSString*)details
}

/**
* Creates a new NSError object based on this RNException
* Creates a new NSError object based on this RNFSException
*/
- (NSError*) error
{
Expand All @@ -22,7 +22,7 @@ - (NSError*) error
];
}

- (RNException*) log
- (RNFSException*) log
{
NSLog(@"%@: %@", self.name, self.reason);
return self;
Expand All @@ -40,29 +40,29 @@ - (void) reject: (RCTPromiseRejectBlock)reject details: (NSString*) details
reject(self.name, reason, [self error]);
}

+ (RNException*) from: (NSException*)exception
+ (RNFSException*) from: (NSException*)exception
{
return [[RNException alloc]
return [[RNFSException alloc]
initWithName: exception.name
reason: exception.reason
userInfo: exception.userInfo
];
}

+ (RNException*) name: (NSString*)name
+ (RNFSException*) name: (NSString*)name
{
return [[RNException alloc] initWithName:name details:nil];
return [[RNFSException alloc] initWithName:name details:nil];
}

+ (RNException*) name: (NSString*)name details:(NSString*)details
+ (RNFSException*) name: (NSString*)name details:(NSString*)details
{
return [[RNException alloc] initWithName:name details:details];
return [[RNFSException alloc] initWithName:name details:details];
}

+ (RNException*) NOT_IMPLEMENTED
+ (RNFSException*) NOT_IMPLEMENTED
{
return [
[RNException alloc]
[RNFSException alloc]
initWithName:@"NOT_IMPLEMENTED"
details:@"This method is not implemented for iOS"
];
Expand Down
109 changes: 108 additions & 1 deletion ios/ReactNativeFs.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,114 @@

@interface ReactNativeFs : RCTEventEmitter <NativeReactNativeFsSpec>
#else
#import <React/RCTBridgeModule.h>
#import <optional>
#import <React/RCTCxxConvert.h>
#import <React/RCTManagedPointer.h>

// These are automatically generated by RN Codegen when using the New Arch,
// however for the backward compatibility to the Old Arch we need to provide
// these ourselves.
namespace JS {
namespace NativeReactNativeFs {
struct FileOptions {
NSString *NSFileProtectionKey() const {
return _v[@"NSFileProtectionKey"];
};
FileOptions(NSDictionary *const v) : _v(v) {}
private:
NSDictionary *_v;
};

struct MkdirOptions {
std::optional<bool> NSURLIsExcludedFromBackupKey() const {
return _v[@"NSURLIsExcludedFromBackupKey"];
}
NSString *NSFileProtectionKey() const {
return _v[@"NSFileProtectionKey"];
}

MkdirOptions(NSDictionary *const v) : _v(v) {}
private:
NSDictionary *_v;
};

struct NativeDownloadFileOptions {
double jobId() const { return [_v[@"jobId"] doubleValue]; }
NSString *fromUrl() const { return _v[@"fromUrl"]; }
NSString *toFile() const { return _v[@"toFile"]; }
bool background() const { return _v[@"background"]; }
double backgroundTimeout() const { return [_v[@"backgroundTimeout"] doubleValue]; }
bool cacheable() const { return _v[@"cacheable"]; }
double connectionTimeout() const { return [_v[@"connectionTimeout"] doubleValue]; }
bool discretionary() const { return _v[@"discretionary"]; }
id<NSObject> headers() const { return _v[@"headers"]; }
double progressDivider() const { return [_v[@"progressDivider"] doubleValue]; }
double progressInterval() const { return [_v[@"progressInterval"] doubleValue]; }
double readTimeout() const { return [_v[@"readTimeout"] doubleValue]; }
bool hasBeginCallback() const { return _v[@"hasBeginCallback"]; }
bool hasProgressCallback() const { return _v[@"hasProgressCallback"]; }
bool hasResumableCallback() const { return _v[@"hasResumableCallback"]; }

NativeDownloadFileOptions(NSDictionary *const v) : _v(v) {}
private:
NSDictionary *_v;
};

typedef NSDictionary NativeUploadFileOptions;
typedef NSDictionary TouchOptions;

/*
struct UploadFileItem {
NSString *name() const;
NSString *filename() const;
NSString *filepath() const;
NSString *filetype() const;
UploadFileItem(NSDictionary *const v) : _v(v) {}
private:
NSDictionary *_v;
};
template <typename T>
using LazyVector = FB::LazyVector<T,id>;
struct NativeUploadFileOptions {
NSString *toUrl() const;
std::optional<bool> binaryStreamOnly() const;
LazyVector<UploadFileItem> files() const;
id<NSObject> _Nullable headers() const;
id<NSObject> _Nullable fields() const;
NSString *method() const;
NativeUploadFileOptions(NSDictionary *const v) : _v(v) {}
private:
NSDictionary *_v;
};
struct TouchOptions {
std::optional<double> ctime() const;
std::optional<double> mtime() const;
TouchOptions(NSDictionary *const v) : _v(v) {}
private:
NSDictionary *_v;
};
*/
}
}

@implementation RCTCxxConvert (NativeReactNativeFs_FileOptions)
+ (RCTManagedPointer *)JS_NativeReactNativeFs_FileOptions:(id)json
{
return facebook::react::managedPointer<JS::NativeReactNativeFs::FileOptions>(json);
}
@end
@implementation RCTCxxConvert (NativeReactNativeFs_MkdirOptions)
+ (RCTManagedPointer *)JS_NativeReactNativeFs_MkdirOptions:(id)json
{
return facebook::react::managedPointer<JS::NativeReactNativeFs::MkdirOptions>(json);
}
@end

@interface ReactNativeFs : RCTEventEmitter <RCTBridgeModule>
#endif
Expand Down
42 changes: 21 additions & 21 deletions ios/ReactNativeFs.mm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#import <CommonCrypto/CommonDigest.h>
#import <Photos/Photos.h>

#import "RNException.h"
#import "RNFSException.h"

typedef void (^CompletionHandler)(void);

Expand Down Expand Up @@ -591,7 +591,7 @@ @implementation ReactNativeFs
resolve:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject)
{
[[RNException NOT_IMPLEMENTED] reject:reject];
[[RNFSException NOT_IMPLEMENTED] reject:reject];
/*
RNFSUploadParams* params = [RNFSUploadParams alloc];
Expand Down Expand Up @@ -898,7 +898,7 @@ @implementation ReactNativeFs
resolve:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject)
{
[[RNException NOT_IMPLEMENTED] reject:reject];
[[RNFSException NOT_IMPLEMENTED] reject:reject];
/*
NSFileManager *manager = [NSFileManager defaultManager];
BOOL exists = [manager fileExistsAtPath:filepath isDirectory:NULL];
Expand Down Expand Up @@ -969,7 +969,7 @@ - (NSDictionary *) getConstants {
}

- (void)appendFile:(NSString *)path b64:(NSString *)b64 resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
[[RNException NOT_IMPLEMENTED] reject:reject details:@"appendFile()"];
[[RNFSException NOT_IMPLEMENTED] reject:reject details:@"appendFile()"];
}


Expand All @@ -979,86 +979,86 @@ - (void)completeHandlerIOS:(double)jobId {


- (void)copyAssetsFileIOS:(NSString *)imageUri destPath:(NSString *)destPath width:(double)width height:(double)height scale:(double)scale compression:(double)compression resizeMode:(NSString *)resizeMode resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
[[RNException NOT_IMPLEMENTED] reject:reject details:@"copyAssetsFileIOS()"];
[[RNFSException NOT_IMPLEMENTED] reject:reject details:@"copyAssetsFileIOS()"];
}


- (void)copyAssetsVideoIOS:(NSString *)imageUri destPath:(NSString *)destPath resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
[[RNException NOT_IMPLEMENTED] reject:reject details:@"copyAssetsVideoIOS()"];
[[RNFSException NOT_IMPLEMENTED] reject:reject details:@"copyAssetsVideoIOS()"];
}


- (void)copyFile:(NSString *)from to:(NSString *)to options:(JS::NativeReactNativeFs::FileOptions &)options resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
[[RNException NOT_IMPLEMENTED] reject:reject details:@"copyFile()"];
[[RNFSException NOT_IMPLEMENTED] reject:reject details:@"copyFile()"];
}


- (void)copyFileAssets:(NSString *)from to:(NSString *)to resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
[[RNException NOT_IMPLEMENTED] reject:reject details:@"copyFileAssets()"];
[[RNFSException NOT_IMPLEMENTED] reject:reject details:@"copyFileAssets()"];
}


- (void)copyFileRes:(NSString *)from to:(NSString *)to resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
[[RNException NOT_IMPLEMENTED] reject:reject details:@"copyFileRes()"];
[[RNFSException NOT_IMPLEMENTED] reject:reject details:@"copyFileRes()"];
}


- (void)copyFolder:(NSString *)from to:(NSString *)to resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
[[RNException NOT_IMPLEMENTED] reject:reject details:@"copyFolder()"];
[[RNFSException NOT_IMPLEMENTED] reject:reject details:@"copyFolder()"];
}

- (void)existsAssets:(NSString *)path resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
[[RNException NOT_IMPLEMENTED] reject:reject details:@"existsAssets()"];
[[RNFSException NOT_IMPLEMENTED] reject:reject details:@"existsAssets()"];
}


- (void)existsRes:(NSString *)path resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
[[RNException NOT_IMPLEMENTED] reject:reject details:@"existsRes()"];
[[RNFSException NOT_IMPLEMENTED] reject:reject details:@"existsRes()"];
}


- (void)getAllExternalFilesDirs:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
[[RNException NOT_IMPLEMENTED] reject:reject details:@"getAllExternalFilesDirs()"];
[[RNFSException NOT_IMPLEMENTED] reject:reject details:@"getAllExternalFilesDirs()"];
}


- (void)moveFile:(NSString *)from to:(NSString *)to options:(JS::NativeReactNativeFs::FileOptions &)options resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
[[RNException NOT_IMPLEMENTED] reject:reject details:@"moveFile()"];
[[RNFSException NOT_IMPLEMENTED] reject:reject details:@"moveFile()"];
}


- (void)readFileAssets:(NSString *)path resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
[[RNException NOT_IMPLEMENTED] reject:reject details:@"readFileAssets()"];
[[RNFSException NOT_IMPLEMENTED] reject:reject details:@"readFileAssets()"];
}


- (void)readFileRes:(NSString *)path resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
[[RNException NOT_IMPLEMENTED] reject:reject details:@"readFileRes()"];
[[RNFSException NOT_IMPLEMENTED] reject:reject details:@"readFileRes()"];
}


- (void)scanFile:(NSString *)path resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
[[RNException NOT_IMPLEMENTED] reject:reject details:@"scanFile()"];
[[RNFSException NOT_IMPLEMENTED] reject:reject details:@"scanFile()"];
}


- (void)scanFile:(NSString *)filepath readable:(BOOL)readable ownerOnly:(BOOL)ownerOnly resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
[[RNException NOT_IMPLEMENTED] reject:reject details:@"scanFile()"];
[[RNFSException NOT_IMPLEMENTED] reject:reject details:@"scanFile()"];
}


- (void)write:(NSString *)path b64:(NSString *)b64 position:(double)position resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
[[RNException NOT_IMPLEMENTED] reject:reject details:@"write()"];
[[RNFSException NOT_IMPLEMENTED] reject:reject details:@"write()"];
}


- (void)readDirAssets:(NSString *)path resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
[[RNException NOT_IMPLEMENTED] reject:reject details:@"readDirAssets()"];
[[RNFSException NOT_IMPLEMENTED] reject:reject details:@"readDirAssets()"];
}


- (void)setReadable:(NSString *)filepath readable:(BOOL)readable ownerOnly:(BOOL)ownerOnly resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
[[RNException NOT_IMPLEMENTED] reject:reject details:@"setReadable()"];
[[RNFSException NOT_IMPLEMENTED] reject:reject details:@"setReadable()"];
}

+(void)setCompletionHandlerForIdentifier: (NSString *)identifier completionHandler: (CompletionHandler)completionHandler
Expand Down
Loading

0 comments on commit affe286

Please sign in to comment.