forked from birdofpreyru/react-native-fs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReactNativeFs.h
151 lines (128 loc) · 5.26 KB
/
ReactNativeFs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#import <React/RCTEventEmitter.h>
#ifdef RCT_NEW_ARCH_ENABLED
#import "RNReactNativeFsSpec.h"
@interface ReactNativeFs : RCTEventEmitter <NativeReactNativeFsSpec,UIDocumentPickerDelegate>
#else
#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 FileOptionsT {
NSString *NSFileProtectionKey() const {
return _v[@"NSFileProtectionKey"];
};
FileOptionsT(NSDictionary *const v) : _v(v) {}
private:
NSDictionary *_v;
};
struct MkdirOptionsT {
std::optional<bool> NSURLIsExcludedFromBackupKey() const {
return [_v[@"NSURLIsExcludedFromBackupKey"] boolValue];
}
NSString *NSFileProtectionKey() const {
return _v[@"NSFileProtectionKey"];
}
MkdirOptionsT(NSDictionary *const v) : _v(v) {}
private:
NSDictionary *_v;
};
struct NativeDownloadFileOptionsT {
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"] boolValue]; }
double backgroundTimeout() const { return [_v[@"backgroundTimeout"] doubleValue]; }
bool cacheable() const { return [_v[@"cacheable"] boolValue]; }
double connectionTimeout() const { return [_v[@"connectionTimeout"] doubleValue]; }
bool discretionary() const { return [_v[@"discretionary"] boolValue]; }
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"] boolValue]; }
bool hasProgressCallback() const { return [_v[@"hasProgressCallback"] boolValue]; }
bool hasResumableCallback() const { return [_v[@"hasResumableCallback"] boolValue]; }
NativeDownloadFileOptionsT(NSDictionary *const v) : _v(v) {}
private:
NSDictionary *_v;
};
typedef NSDictionary NativeUploadFileOptions;
/*
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 NativeUploadFileOptionsT {
double jobId() const { return [_v[@"jobId"] doubleValue]; }
NSString *toUrl() const { return _v[@"toUrl"]; }
std::optional<bool> binaryStreamOnly() const {
return [_v[@"binaryStreamOnly"] boolValue];
}
id<NSObject> files() const { return _v[@"files"]; }
id<NSObject> _Nullable headers() const { return _v[@"headers"]; }
id<NSObject> _Nullable fields() const { return _v[@"fields"]; }
NSString *method() const { return _v[@"method"]; }
bool hasBeginCallback() const { return [_v[@"hasBeginCallback"] boolValue]; }
bool hasProgressCallback() const { return [_v[@"hasProgressCallback"] boolValue]; }
NativeUploadFileOptionsT(NSDictionary *const v) : _v(v) {}
private:
NSDictionary *_v;
};
struct TouchOptions {
std::optional<double> ctime() const { return [_v[@"ctime"] doubleValue]; }
std::optional<double> mtime() const { return [_v[@"mtime"] doubleValue]; }
TouchOptions(NSDictionary *const v) : _v(v) {}
private:
NSDictionary *_v;
};
}
}
@implementation RCTCxxConvert (NativeReactNativeFs_FileOptionsT)
+ (RCTManagedPointer *)JS_NativeReactNativeFs_FileOptionsT:(id)json
{
return facebook::react::managedPointer<JS::NativeReactNativeFs::FileOptionsT>(json);
}
@end
@implementation RCTCxxConvert (NativeReactNativeFs_MkdirOptionsT)
+ (RCTManagedPointer *)JS_NativeReactNativeFs_MkdirOptionsT:(id)json
{
return facebook::react::managedPointer<JS::NativeReactNativeFs::MkdirOptionsT>(json);
}
@end
@implementation RCTCxxConvert (NativeReactNativeFs_NativeDownloadFileOptionsT)
+ (RCTManagedPointer *)JS_NativeReactNativeFs_NativeDownloadFileOptionsT:(id)json
{
return facebook::react::managedPointer<JS::NativeReactNativeFs::NativeDownloadFileOptionsT>(json);
}
@end
@implementation RCTCxxConvert (NativeReactNativeFs_NativeUploadFileOptionsT)
+ (RCTManagedPointer *)JS_NativeReactNativeFs_NativeUploadFileOptionsT:(id)json
{
return facebook::react::managedPointer<JS::NativeReactNativeFs::NativeUploadFileOptionsT>(json);
}
@end
@implementation RCTCxxConvert (TouchOptions)
+ (RCTManagedPointer *)JS_NativeReactNativeFs_TouchOptions:(id)json
{
return
facebook::react::managedPointer<JS::NativeReactNativeFs::TouchOptions>(json);
}
@end
@interface ReactNativeFs : RCTEventEmitter <RCTBridgeModule,UIDocumentPickerDelegate>
#endif
@property (retain) NSMutableDictionary* downloaders;
@property (retain) NSMutableDictionary* uuids;
@property (retain) NSMutableDictionary* uploaders;
@end