expo-file-system 19.0.6 → 19.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/android/build.gradle +2 -2
- package/android/src/main/java/expo/modules/filesystem/FileSystemDirectory.kt +7 -0
- package/android/src/main/java/expo/modules/filesystem/FileSystemModule.kt +19 -5
- package/android/src/main/java/expo/modules/filesystem/FileSystemNextRecords.kt +3 -1
- package/android/src/main/java/expo/modules/filesystem/FileSystemPath.kt +14 -0
- package/android/src/main/java/expo/modules/filesystem/legacy/FileSystemLegacyModule.kt +11 -5
- package/build/ExpoFileSystem.types.d.ts +39 -10
- package/build/ExpoFileSystem.types.d.ts.map +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.d.ts.map +1 -1
- package/expo-module.config.json +1 -1
- package/ios/FilePickingHandler.swift +87 -0
- package/ios/FilePickingUtils.swift +133 -0
- package/ios/FileSystemDirectory.swift +10 -0
- package/ios/FileSystemExceptions.swift +24 -0
- package/ios/FileSystemModule.swift +40 -7
- package/ios/FileSystemPath.swift +13 -0
- package/ios/FileSystemRecords.swift +1 -0
- package/ios/Legacy/FileSystemLegacyModule.swift +10 -6
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.8/expo.modules.filesystem-19.0.8-sources.jar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.8/expo.modules.filesystem-19.0.8-sources.jar.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.8/expo.modules.filesystem-19.0.8-sources.jar.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.8/expo.modules.filesystem-19.0.8-sources.jar.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.8/expo.modules.filesystem-19.0.8-sources.jar.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.8/expo.modules.filesystem-19.0.8.aar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.8/expo.modules.filesystem-19.0.8.aar.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.8/expo.modules.filesystem-19.0.8.aar.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.8/expo.modules.filesystem-19.0.8.aar.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.8/expo.modules.filesystem-19.0.8.aar.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/{19.0.6/expo.modules.filesystem-19.0.6.module → 19.0.8/expo.modules.filesystem-19.0.8.module} +22 -22
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.8/expo.modules.filesystem-19.0.8.module.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.8/expo.modules.filesystem-19.0.8.module.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.8/expo.modules.filesystem-19.0.8.module.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.8/expo.modules.filesystem-19.0.8.module.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/{19.0.6/expo.modules.filesystem-19.0.6.pom → 19.0.8/expo.modules.filesystem-19.0.8.pom} +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.8/expo.modules.filesystem-19.0.8.pom.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.8/expo.modules.filesystem-19.0.8.pom.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.8/expo.modules.filesystem-19.0.8.pom.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.8/expo.modules.filesystem-19.0.8.pom.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/maven-metadata.xml +4 -4
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/maven-metadata.xml.md5 +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/maven-metadata.xml.sha1 +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/maven-metadata.xml.sha256 +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/maven-metadata.xml.sha512 +1 -1
- package/package.json +4 -4
- package/src/ExpoFileSystem.types.ts +42 -10
- package/src/index.ts +2 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.6/expo.modules.filesystem-19.0.6-sources.jar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.6/expo.modules.filesystem-19.0.6-sources.jar.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.6/expo.modules.filesystem-19.0.6-sources.jar.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.6/expo.modules.filesystem-19.0.6-sources.jar.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.6/expo.modules.filesystem-19.0.6-sources.jar.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.6/expo.modules.filesystem-19.0.6.aar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.6/expo.modules.filesystem-19.0.6.aar.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.6/expo.modules.filesystem-19.0.6.aar.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.6/expo.modules.filesystem-19.0.6.aar.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.6/expo.modules.filesystem-19.0.6.aar.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.6/expo.modules.filesystem-19.0.6.module.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.6/expo.modules.filesystem-19.0.6.module.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.6/expo.modules.filesystem-19.0.6.module.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.6/expo.modules.filesystem-19.0.6.module.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.6/expo.modules.filesystem-19.0.6.pom.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.6/expo.modules.filesystem-19.0.6.pom.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.6/expo.modules.filesystem-19.0.6.pom.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.6/expo.modules.filesystem-19.0.6.pom.sha512 +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,19 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 19.0.8 — 2025-09-02
|
|
14
|
+
|
|
15
|
+
### 🎉 New features
|
|
16
|
+
|
|
17
|
+
- [iOS] Add `pickFileAsync` support ([#39173](https://github.com/expo/expo/pull/39173) by [@kosmydel](https://github.com/kosmydel))
|
|
18
|
+
|
|
19
|
+
## 19.0.7 — 2025-08-31
|
|
20
|
+
|
|
21
|
+
### 🎉 New features
|
|
22
|
+
|
|
23
|
+
- Add `rename` method for files and directories ([#39138](https://github.com/expo/expo/pull/39138) by [@kosmydel](https://github.com/kosmydel))
|
|
24
|
+
- Add `idempotent` option for creating directories ([#39121](https://github.com/expo/expo/pull/39121) by [@kosmydel](https://github.com/kosmydel))
|
|
25
|
+
|
|
13
26
|
## 19.0.6 — 2025-08-26
|
|
14
27
|
|
|
15
28
|
_This version does not introduce any user-facing changes._
|
|
@@ -37,6 +50,7 @@ _This version does not introduce any user-facing changes._
|
|
|
37
50
|
### 💡 Others
|
|
38
51
|
|
|
39
52
|
- Update typings for `typescript@5.9` ([#38833](https://github.com/expo/expo/pull/38833) by [@kitten](https://github.com/kitten))
|
|
53
|
+
- Change Constants to Constant/Property. ([#38926](https://github.com/expo/expo/pull/38926) by [@jakex7](https://github.com/jakex7))
|
|
40
54
|
|
|
41
55
|
## 19.0.0 — 2025-08-13
|
|
42
56
|
|
package/android/build.gradle
CHANGED
|
@@ -53,6 +53,9 @@ class FileSystemDirectory(uri: Uri) : FileSystemPath(uri) {
|
|
|
53
53
|
fun create(options: CreateOptions = CreateOptions()) {
|
|
54
54
|
validateType()
|
|
55
55
|
validatePermission(Permission.WRITE)
|
|
56
|
+
if (!needsCreation(options)) {
|
|
57
|
+
return
|
|
58
|
+
}
|
|
56
59
|
validateCanCreate(options)
|
|
57
60
|
if (uri.isContentUri) {
|
|
58
61
|
throw UnableToCreateException("create function does not work with SAF Uris, use `createDirectory` and `createFile` instead")
|
|
@@ -101,4 +104,8 @@ class FileSystemDirectory(uri: Uri) : FileSystemPath(uri) {
|
|
|
101
104
|
val uriString = file.uri.toString()
|
|
102
105
|
return if (uriString.endsWith("/")) uriString else "$uriString/"
|
|
103
106
|
}
|
|
107
|
+
|
|
108
|
+
fun needsCreation(options: CreateOptions): Boolean {
|
|
109
|
+
return !file.exists() || !options.idempotent
|
|
110
|
+
}
|
|
104
111
|
}
|
|
@@ -28,11 +28,17 @@ class FileSystemModule : Module() {
|
|
|
28
28
|
override fun definition() = ModuleDefinition {
|
|
29
29
|
Name("FileSystem")
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
)
|
|
31
|
+
Constant("documentDirectory") {
|
|
32
|
+
Uri.fromFile(context.filesDir).toString() + "/"
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
Constant("cacheDirectory") {
|
|
36
|
+
Uri.fromFile(context.cacheDir).toString() + "/"
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
Constant("bundleDirectory") {
|
|
40
|
+
"asset://"
|
|
41
|
+
}
|
|
36
42
|
|
|
37
43
|
Property("totalDiskSpace") {
|
|
38
44
|
File(context.filesDir.path).totalSpace
|
|
@@ -193,6 +199,10 @@ class FileSystemModule : Module() {
|
|
|
193
199
|
file.move(destination)
|
|
194
200
|
}
|
|
195
201
|
|
|
202
|
+
Function("rename") { file: FileSystemFile, newName: String ->
|
|
203
|
+
file.rename(newName)
|
|
204
|
+
}
|
|
205
|
+
|
|
196
206
|
Property("uri") { file ->
|
|
197
207
|
file.asString()
|
|
198
208
|
}
|
|
@@ -286,6 +296,10 @@ class FileSystemModule : Module() {
|
|
|
286
296
|
directory.move(destination)
|
|
287
297
|
}
|
|
288
298
|
|
|
299
|
+
Function("rename") { directory: FileSystemDirectory, newName: String ->
|
|
300
|
+
directory.rename(newName)
|
|
301
|
+
}
|
|
302
|
+
|
|
289
303
|
Property("uri") { directory ->
|
|
290
304
|
directory.asString()
|
|
291
305
|
}
|
|
@@ -163,6 +163,20 @@ abstract class FileSystemPath(var uri: Uri) : SharedObject() {
|
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
+
fun rename(newName: String) {
|
|
167
|
+
validateType()
|
|
168
|
+
validatePermission(Permission.WRITE)
|
|
169
|
+
val newFile = File(javaFile.parent, newName)
|
|
170
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
171
|
+
javaFile.toPath().moveTo(newFile.toPath())
|
|
172
|
+
uri = newFile.toUri()
|
|
173
|
+
} else {
|
|
174
|
+
javaFile.copyTo(newFile)
|
|
175
|
+
javaFile.delete()
|
|
176
|
+
uri = newFile.toUri()
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
166
180
|
val modificationTime: Long? get() {
|
|
167
181
|
validateType()
|
|
168
182
|
return file.lastModified()
|
|
@@ -89,11 +89,17 @@ open class FileSystemLegacyModule : Module() {
|
|
|
89
89
|
override fun definition() = ModuleDefinition {
|
|
90
90
|
Name("ExponentFileSystem")
|
|
91
91
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
)
|
|
92
|
+
Constant("documentDirectory") {
|
|
93
|
+
Uri.fromFile(context.filesDir).toString() + "/"
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
Constant("cacheDirectory") {
|
|
97
|
+
Uri.fromFile(context.cacheDir).toString() + "/"
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
Constant("bundleDirectory") {
|
|
101
|
+
"asset:///"
|
|
102
|
+
}
|
|
97
103
|
|
|
98
104
|
Events(
|
|
99
105
|
EXDownloadProgressEventName,
|
|
@@ -1,15 +1,37 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type FileCreateOptions = {
|
|
2
2
|
/**
|
|
3
3
|
* Whether to create intermediate directories if they do not exist.
|
|
4
4
|
* @default false
|
|
5
5
|
*/
|
|
6
6
|
intermediates?: boolean;
|
|
7
7
|
/**
|
|
8
|
-
* Whether to overwrite the file
|
|
8
|
+
* Whether to overwrite the file if it exists.
|
|
9
9
|
* @default false
|
|
10
10
|
*/
|
|
11
11
|
overwrite?: boolean;
|
|
12
12
|
};
|
|
13
|
+
export type DirectoryCreateOptions = {
|
|
14
|
+
/**
|
|
15
|
+
* Whether to create intermediate directories if they do not exist.
|
|
16
|
+
* @default false
|
|
17
|
+
*/
|
|
18
|
+
intermediates?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Whether to overwrite the directory if it exists.
|
|
21
|
+
* @default false
|
|
22
|
+
*/
|
|
23
|
+
overwrite?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* This flag controls whether the `create` operation is idempotent
|
|
26
|
+
* (safe to call multiple times without error).
|
|
27
|
+
*
|
|
28
|
+
* If `true`, creating a file or directory that already exists will succeed silently.
|
|
29
|
+
* If `false`, an error will be thrown when the target already exists.
|
|
30
|
+
*
|
|
31
|
+
* @default false
|
|
32
|
+
*/
|
|
33
|
+
idempotent?: boolean;
|
|
34
|
+
};
|
|
13
35
|
export declare class Directory {
|
|
14
36
|
/**
|
|
15
37
|
* Creates an instance of a directory.
|
|
@@ -42,9 +64,9 @@ export declare class Directory {
|
|
|
42
64
|
/**
|
|
43
65
|
* Creates a directory that the current uri points to.
|
|
44
66
|
*
|
|
45
|
-
* @throws Error if the containing folder doesn't exist, the application has no read access to it or the directory (or a file with the same path) already exists.
|
|
67
|
+
* @throws Error if the containing folder doesn't exist, the application has no read access to it or the directory (or a file with the same path) already exists (unless `idempotent` is `true`).
|
|
46
68
|
*/
|
|
47
|
-
create(options?:
|
|
69
|
+
create(options?: DirectoryCreateOptions): void;
|
|
48
70
|
createFile(name: string, mimeType: string | null): File;
|
|
49
71
|
createDirectory(name: string): Directory;
|
|
50
72
|
/**
|
|
@@ -55,6 +77,10 @@ export declare class Directory {
|
|
|
55
77
|
* Moves a directory. Updates the `uri` property that now points to the new location.
|
|
56
78
|
*/
|
|
57
79
|
move(destination: Directory | File): void;
|
|
80
|
+
/**
|
|
81
|
+
* Renames a directory.
|
|
82
|
+
*/
|
|
83
|
+
rename(newName: string): void;
|
|
58
84
|
/**
|
|
59
85
|
* @hidden
|
|
60
86
|
* Lists the contents of a directory. Should not be used directly, as it returns a list of paths.
|
|
@@ -172,7 +198,7 @@ export declare class File {
|
|
|
172
198
|
*
|
|
173
199
|
* @throws Error if the containing folder doesn't exist, the application has no read access to it or the file (or directory with the same path) already exists.
|
|
174
200
|
*/
|
|
175
|
-
create(options?:
|
|
201
|
+
create(options?: FileCreateOptions): void;
|
|
176
202
|
/**
|
|
177
203
|
* Copies a file.
|
|
178
204
|
*/
|
|
@@ -181,6 +207,10 @@ export declare class File {
|
|
|
181
207
|
* Moves a directory. Updates the `uri` property that now points to the new location.
|
|
182
208
|
*/
|
|
183
209
|
move(destination: Directory | File): void;
|
|
210
|
+
/**
|
|
211
|
+
* Renames a file.
|
|
212
|
+
*/
|
|
213
|
+
rename(newName: string): void;
|
|
184
214
|
/**
|
|
185
215
|
* Returns A `FileHandle` object that can be used to read and write data to the file.
|
|
186
216
|
* @throws Error if the file does not exist or cannot be opened.
|
|
@@ -201,16 +231,15 @@ export declare class File {
|
|
|
201
231
|
*/
|
|
202
232
|
static downloadFileAsync(url: string, destination: Directory | File, options?: DownloadOptions): Promise<File>;
|
|
203
233
|
/**
|
|
204
|
-
* A static method that opens a file picker to select a single file of specified type.
|
|
234
|
+
* A static method that opens a file picker to select a single file of specified type. On iOS, it returns a temporary copy of the file leaving the original file untouched.
|
|
205
235
|
*
|
|
206
|
-
*
|
|
236
|
+
* Selecting multiple files is not supported yet.
|
|
207
237
|
*
|
|
208
238
|
* @param initialUri An optional URI pointing to an initial folder on which the file picker is opened.
|
|
209
239
|
* @param mimeType A mime type that is used to filter out files that can be picked out.
|
|
210
|
-
* @returns a `File` instance.
|
|
211
|
-
* @platform android
|
|
240
|
+
* @returns a `File` instance or an array of `File` instances.
|
|
212
241
|
*/
|
|
213
|
-
static pickFileAsync(initialUri?: string, mimeType?: string): Promise<File>;
|
|
242
|
+
static pickFileAsync(initialUri?: string, mimeType?: string): Promise<File | File[]>;
|
|
214
243
|
/**
|
|
215
244
|
* A size of the file in bytes. 0 if the file does not exist, or it cannot be read.
|
|
216
245
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoFileSystem.types.d.ts","sourceRoot":"","sources":["../src/ExpoFileSystem.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"ExpoFileSystem.types.d.ts","sourceRoot":"","sources":["../src/ExpoFileSystem.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,SAA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G;IACH,MAAM,EAAE,OAAO,CAAC;IAChB;;OAEG;IACH,WAAW,EAAE,OAAO,GAAG,IAAI,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B;;OAEG;IACH,MAAM,EAAE,OAAO,CAAC;IAChB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC"}
|
package/build/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export * from './FileSystem';
|
|
2
|
-
export { type
|
|
2
|
+
export { type FileCreateOptions, type DirectoryCreateOptions, type FileHandle, type FileInfo, type InfoOptions, type PathInfo, type DirectoryInfo, } from './ExpoFileSystem.types';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAE7B,OAAO,EACL,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAE7B,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,QAAQ,EACb,KAAK,aAAa,GACnB,MAAM,wBAAwB,CAAC"}
|
package/expo-module.config.json
CHANGED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// UIKit is unavailable on macOS, so platform checks are necessary.
|
|
2
|
+
// For macOS support, we should consider using NSOpenPanel: https://developer.apple.com/documentation/appkit/nsopenpanel
|
|
3
|
+
#if os(iOS) || os(tvOS)
|
|
4
|
+
import ExpoModulesCore
|
|
5
|
+
import UIKit
|
|
6
|
+
|
|
7
|
+
internal class FilePickingHandler: FilePickingResultHandler {
|
|
8
|
+
private weak var module: FileSystemModule?
|
|
9
|
+
internal var filePickingContext: FilePickingContext?
|
|
10
|
+
|
|
11
|
+
init(module: FileSystemModule) {
|
|
12
|
+
self.module = module
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
func presentDocumentPicker(
|
|
16
|
+
picker: UIDocumentPickerViewController,
|
|
17
|
+
isDirectory: Bool,
|
|
18
|
+
initialUri: URL?,
|
|
19
|
+
mimeType: String?,
|
|
20
|
+
promise: Promise
|
|
21
|
+
) {
|
|
22
|
+
guard let module = module else {
|
|
23
|
+
promise.reject(MissingViewControllerException())
|
|
24
|
+
return
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if filePickingContext != nil {
|
|
28
|
+
promise.reject(PickingInProgressException())
|
|
29
|
+
return
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
guard let currentVc = module.appContext?.utilities?.currentViewController() else {
|
|
33
|
+
promise.reject(MissingViewControllerException())
|
|
34
|
+
return
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let pickerDelegate = FilePickingDelegate(resultHandler: self, isDirectory: isDirectory)
|
|
38
|
+
filePickingContext = FilePickingContext(
|
|
39
|
+
promise: promise,
|
|
40
|
+
initialUri: initialUri,
|
|
41
|
+
mimeType: mimeType,
|
|
42
|
+
isDirectory: isDirectory,
|
|
43
|
+
delegate: pickerDelegate
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
picker.delegate = pickerDelegate
|
|
47
|
+
picker.presentationController?.delegate = pickerDelegate
|
|
48
|
+
picker.allowsMultipleSelection = false
|
|
49
|
+
|
|
50
|
+
if UIDevice.current.userInterfaceIdiom == .pad {
|
|
51
|
+
let viewFrame = currentVc.view.frame
|
|
52
|
+
picker.popoverPresentationController?.sourceRect = CGRect(
|
|
53
|
+
x: viewFrame.midX,
|
|
54
|
+
y: viewFrame.maxY,
|
|
55
|
+
width: 0,
|
|
56
|
+
height: 0
|
|
57
|
+
)
|
|
58
|
+
picker.popoverPresentationController?.sourceView = currentVc.view
|
|
59
|
+
picker.modalPresentationStyle = .pageSheet
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
currentVc.present(picker, animated: true)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
func didPickFileAt(url: URL) {
|
|
66
|
+
handlePickingResult { context in
|
|
67
|
+
let file = FileSystemFile(url: url)
|
|
68
|
+
context.promise.resolve(file)
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
func didCancelPicking() {
|
|
73
|
+
handlePickingResult { context in
|
|
74
|
+
context.promise.reject(FilePickingCancelledException())
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
private func handlePickingResult(_ handler: (FilePickingContext) -> Void) {
|
|
79
|
+
guard let context = filePickingContext else {
|
|
80
|
+
return
|
|
81
|
+
}
|
|
82
|
+
filePickingContext = nil
|
|
83
|
+
|
|
84
|
+
handler(context)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
#endif
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
#if os(iOS) || os(tvOS)
|
|
2
|
+
import ExpoModulesCore
|
|
3
|
+
import MobileCoreServices
|
|
4
|
+
import UIKit
|
|
5
|
+
import UniformTypeIdentifiers
|
|
6
|
+
|
|
7
|
+
internal protocol FilePickingResultHandler {
|
|
8
|
+
func didPickFileAt(url: URL)
|
|
9
|
+
func didCancelPicking()
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
internal struct FilePickingContext {
|
|
13
|
+
let promise: Promise
|
|
14
|
+
let initialUri: URL?
|
|
15
|
+
let mimeType: String?
|
|
16
|
+
let isDirectory: Bool
|
|
17
|
+
let delegate: FilePickingDelegate
|
|
18
|
+
var pickedUrl: URL?
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
internal class FilePickingDelegate: NSObject, UIDocumentPickerDelegate, UIAdaptivePresentationControllerDelegate {
|
|
22
|
+
private let resultHandler: FilePickingResultHandler
|
|
23
|
+
private let isDirectory: Bool
|
|
24
|
+
private weak var pickingHandler: FilePickingHandler?
|
|
25
|
+
|
|
26
|
+
init(resultHandler: FilePickingResultHandler, isDirectory: Bool = false) {
|
|
27
|
+
self.resultHandler = resultHandler
|
|
28
|
+
self.isDirectory = isDirectory
|
|
29
|
+
self.pickingHandler = resultHandler as? FilePickingHandler
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
|
|
33
|
+
guard let url = urls.first else {
|
|
34
|
+
self.resultHandler.didCancelPicking()
|
|
35
|
+
return
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
self.resultHandler.didPickFileAt(url: url)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) {
|
|
42
|
+
self.resultHandler.didCancelPicking()
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
func presentationControllerDidDismiss(_ presentationController: UIPresentationController) {
|
|
46
|
+
self.resultHandler.didCancelPicking()
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
internal func createFilePicker(initialUri: URL?, mimeType: String?) -> UIDocumentPickerViewController {
|
|
51
|
+
if #available(iOS 14.0, *) {
|
|
52
|
+
let utTypes: [UTType]
|
|
53
|
+
if let mimeType = mimeType {
|
|
54
|
+
if let utType = UTType(mimeType: mimeType) {
|
|
55
|
+
utTypes = [utType]
|
|
56
|
+
} else {
|
|
57
|
+
utTypes = [UTType.item]
|
|
58
|
+
}
|
|
59
|
+
} else {
|
|
60
|
+
utTypes = [UTType.item]
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
let picker = UIDocumentPickerViewController(forOpeningContentTypes: utTypes, asCopy: true)
|
|
64
|
+
|
|
65
|
+
if let initialUri = initialUri {
|
|
66
|
+
picker.directoryURL = initialUri
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return picker
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
let utiTypes: [String]
|
|
73
|
+
if let mimeType = mimeType {
|
|
74
|
+
utiTypes = [toUTI(mimeType: mimeType)]
|
|
75
|
+
} else {
|
|
76
|
+
utiTypes = [kUTTypeItem as String]
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
let picker = UIDocumentPickerViewController(documentTypes: utiTypes, in: .import)
|
|
80
|
+
|
|
81
|
+
if let initialUri = initialUri {
|
|
82
|
+
picker.directoryURL = initialUri
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return picker
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
@available(iOS 14.0, *)
|
|
89
|
+
private func toUTType(mimeType: String) -> UTType? {
|
|
90
|
+
switch mimeType {
|
|
91
|
+
case "*/*":
|
|
92
|
+
return UTType.item
|
|
93
|
+
case "image/*":
|
|
94
|
+
return UTType.image
|
|
95
|
+
case "video/*":
|
|
96
|
+
return UTType.movie
|
|
97
|
+
case "audio/*":
|
|
98
|
+
return UTType.audio
|
|
99
|
+
case "text/*":
|
|
100
|
+
return UTType.text
|
|
101
|
+
default:
|
|
102
|
+
return UTType(mimeType: mimeType)
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
private func toUTI(mimeType: String) -> String {
|
|
107
|
+
var uti: CFString
|
|
108
|
+
|
|
109
|
+
switch mimeType {
|
|
110
|
+
case "*/*":
|
|
111
|
+
uti = kUTTypeItem
|
|
112
|
+
case "image/*":
|
|
113
|
+
uti = kUTTypeImage
|
|
114
|
+
case "video/*":
|
|
115
|
+
uti = kUTTypeVideo
|
|
116
|
+
case "audio/*":
|
|
117
|
+
uti = kUTTypeAudio
|
|
118
|
+
case "text/*":
|
|
119
|
+
uti = kUTTypeText
|
|
120
|
+
default:
|
|
121
|
+
if let ref = UTTypeCreatePreferredIdentifierForTag(
|
|
122
|
+
kUTTagClassMIMEType,
|
|
123
|
+
mimeType as CFString,
|
|
124
|
+
nil
|
|
125
|
+
)?.takeRetainedValue() {
|
|
126
|
+
uti = ref
|
|
127
|
+
} else {
|
|
128
|
+
uti = kUTTypeItem
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return uti as String
|
|
132
|
+
}
|
|
133
|
+
#endif
|
|
@@ -19,6 +19,9 @@ internal final class FileSystemDirectory: FileSystemPath {
|
|
|
19
19
|
func create(_ options: CreateOptions) throws {
|
|
20
20
|
try validatePermission(.write)
|
|
21
21
|
try validateType()
|
|
22
|
+
guard try needsCreation(options) else {
|
|
23
|
+
return
|
|
24
|
+
}
|
|
22
25
|
try validateCanCreate(options)
|
|
23
26
|
do {
|
|
24
27
|
try FileManager.default.createDirectory(at: url, withIntermediateDirectories: options.intermediates, attributes: nil)
|
|
@@ -97,4 +100,11 @@ internal final class FileSystemDirectory: FileSystemPath {
|
|
|
97
100
|
throw UnableToGetInfoException("url scheme \(String(describing: url.scheme)) is not supported")
|
|
98
101
|
}
|
|
99
102
|
}
|
|
103
|
+
|
|
104
|
+
func needsCreation(_ options: CreateOptions) throws -> Bool {
|
|
105
|
+
if !exists {
|
|
106
|
+
return true
|
|
107
|
+
}
|
|
108
|
+
return !options.idempotent
|
|
109
|
+
}
|
|
100
110
|
}
|
|
@@ -72,3 +72,27 @@ internal final class MissingPermissionException: GenericException<String> {
|
|
|
72
72
|
"Missing permission for uri: \(param)"
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
+
|
|
76
|
+
internal final class PickingInProgressException: Exception {
|
|
77
|
+
override var reason: String {
|
|
78
|
+
"File picking is already in progress"
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
internal final class MissingViewControllerException: Exception {
|
|
83
|
+
override var reason: String {
|
|
84
|
+
"No view controller available for presenting file picker"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
internal final class FilePickingCancelledException: Exception {
|
|
89
|
+
override var reason: String {
|
|
90
|
+
"File picking was cancelled by the user"
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
internal final class FeatureNotAvailableOnPlatformException: Exception {
|
|
95
|
+
override var reason: String {
|
|
96
|
+
"This feature is not available on this platform"
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -4,6 +4,10 @@ import ExpoModulesCore
|
|
|
4
4
|
|
|
5
5
|
@available(iOS 14, tvOS 14, *)
|
|
6
6
|
public final class FileSystemModule: Module {
|
|
7
|
+
#if os(iOS) || os(tvOS)
|
|
8
|
+
private lazy var filePickingHandler = FilePickingHandler(module: self)
|
|
9
|
+
#endif
|
|
10
|
+
|
|
7
11
|
var documentDirectory: URL? {
|
|
8
12
|
return appContext?.config.documentDirectory
|
|
9
13
|
}
|
|
@@ -31,13 +35,20 @@ public final class FileSystemModule: Module {
|
|
|
31
35
|
public func definition() -> ModuleDefinition {
|
|
32
36
|
Name("FileSystem")
|
|
33
37
|
|
|
34
|
-
|
|
35
|
-
return
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
Constant("documentDirectory") {
|
|
39
|
+
return documentDirectory?.absoluteString
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
Constant("cacheDirectory") {
|
|
43
|
+
return cacheDirectory?.absoluteString
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
Constant("bundleDirectory") {
|
|
47
|
+
return Bundle.main.bundlePath
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
Constant("appleSharedContainers") {
|
|
51
|
+
return getAppleSharedContainers()
|
|
41
52
|
}
|
|
42
53
|
|
|
43
54
|
Property("totalDiskSpace") {
|
|
@@ -95,6 +106,20 @@ public final class FileSystemModule: Module {
|
|
|
95
106
|
downloadTask.resume()
|
|
96
107
|
}
|
|
97
108
|
|
|
109
|
+
AsyncFunction("pickFileAsync") { (initialUri: URL?, mimeType: String?, promise: Promise) in
|
|
110
|
+
#if os(iOS) || os(tvOS)
|
|
111
|
+
filePickingHandler.presentDocumentPicker(
|
|
112
|
+
picker: createFilePicker(initialUri: initialUri, mimeType: mimeType),
|
|
113
|
+
isDirectory: false,
|
|
114
|
+
initialUri: initialUri,
|
|
115
|
+
mimeType: mimeType,
|
|
116
|
+
promise: promise
|
|
117
|
+
)
|
|
118
|
+
#else
|
|
119
|
+
promise.reject(FeatureNotAvailableOnPlatformException())
|
|
120
|
+
#endif
|
|
121
|
+
}.runOnQueue(.main)
|
|
122
|
+
|
|
98
123
|
Function("info") { (url: URL) in
|
|
99
124
|
let output = PathInfo()
|
|
100
125
|
output.exists = false
|
|
@@ -208,6 +233,10 @@ public final class FileSystemModule: Module {
|
|
|
208
233
|
try file.move(to: to)
|
|
209
234
|
}
|
|
210
235
|
|
|
236
|
+
Function("rename") { (file, newName: String) in
|
|
237
|
+
try file.rename(newName)
|
|
238
|
+
}
|
|
239
|
+
|
|
211
240
|
Property("uri") { file in
|
|
212
241
|
return file.url.absoluteString
|
|
213
242
|
}
|
|
@@ -272,6 +301,10 @@ public final class FileSystemModule: Module {
|
|
|
272
301
|
try directory.move(to: to)
|
|
273
302
|
}
|
|
274
303
|
|
|
304
|
+
Function("rename") { (directory, newName: String) in
|
|
305
|
+
try directory.rename(newName)
|
|
306
|
+
}
|
|
307
|
+
|
|
275
308
|
// this function is internal and will be removed in the future (when returning arrays of shared objects is supported)
|
|
276
309
|
Function("listAsRecords") { directory in
|
|
277
310
|
try directory.listAsRecords()
|
package/ios/FileSystemPath.swift
CHANGED
|
@@ -76,6 +76,19 @@ internal class FileSystemPath: SharedObject {
|
|
|
76
76
|
url = destinationUrl
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
func getRenamedUrl(newName: String) -> URL {
|
|
80
|
+
return url.deletingLastPathComponent().appendingPathComponent(newName)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
func rename(_ newName: String) throws {
|
|
84
|
+
try validatePermission(.write)
|
|
85
|
+
let newUrl = getRenamedUrl(newName: newName)
|
|
86
|
+
try FileManager.default.moveItem(at: url, to: newUrl)
|
|
87
|
+
// Refetch the URL to ensure it has the correct trailing slash, which differs for directories and files.
|
|
88
|
+
let updatedUrl = getRenamedUrl(newName: newName)
|
|
89
|
+
url = updatedUrl
|
|
90
|
+
}
|
|
91
|
+
|
|
79
92
|
var modificationTime: Int64 {
|
|
80
93
|
get throws {
|
|
81
94
|
let modificationDate: Date = try getAttribute(.modificationDate, atPath: url.path)
|
|
@@ -27,12 +27,16 @@ public final class FileSystemLegacyModule: Module {
|
|
|
27
27
|
public func definition() -> ModuleDefinition {
|
|
28
28
|
Name("ExponentFileSystem")
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
return
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
Constant("documentDirectory") {
|
|
31
|
+
return documentDirectory?.absoluteString
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
Constant("cacheDirectory") {
|
|
35
|
+
return cacheDirectory?.absoluteString
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
Constant("bundleDirectory") {
|
|
39
|
+
return Bundle.main.bundlePath
|
|
36
40
|
}
|
|
37
41
|
|
|
38
42
|
Events(EVENT_DOWNLOAD_PROGRESS, EVENT_UPLOAD_PROGRESS)
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
792cb40c62c2c908a410b672981f14b0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1c9d91c71b0534cc4967a352ccb7864aa71054c1
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
267e88a3c5d6745c834050282f9a45c0305f51c7b8554e18e0b68a16ab337edb
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
b8f0a84aa8f6377f6fb162699e663d8e9de63caff453a37513e1cfeeaaa050261f8ae32032f15e8968e8591d518531d46e8e549c745b2998ee16fc7578903872
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
5af511777ab5671351368ebf881eb54b
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
91a70d10d282ea3c01290747edd6b4f19226ad65
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
25644f10378a71e515dcfe1df64fb41fef0862fdfbe9cf52ac91675939cd76fb
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
56d4b780eb2b6164377db2d9756e9d1d6872436d2313f75a77b4ffce8be47d92c2fc502cc87369554a595d1844763bdb6ce3d14dc68ef849379070a259f920f3
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"component": {
|
|
4
4
|
"group": "host.exp.exponent",
|
|
5
5
|
"module": "expo.modules.filesystem",
|
|
6
|
-
"version": "19.0.
|
|
6
|
+
"version": "19.0.8",
|
|
7
7
|
"attributes": {
|
|
8
8
|
"org.gradle.status": "release"
|
|
9
9
|
}
|
|
@@ -75,13 +75,13 @@
|
|
|
75
75
|
],
|
|
76
76
|
"files": [
|
|
77
77
|
{
|
|
78
|
-
"name": "expo.modules.filesystem-19.0.
|
|
79
|
-
"url": "expo.modules.filesystem-19.0.
|
|
80
|
-
"size":
|
|
81
|
-
"sha512": "
|
|
82
|
-
"sha256": "
|
|
83
|
-
"sha1": "
|
|
84
|
-
"md5": "
|
|
78
|
+
"name": "expo.modules.filesystem-19.0.8.aar",
|
|
79
|
+
"url": "expo.modules.filesystem-19.0.8.aar",
|
|
80
|
+
"size": 386221,
|
|
81
|
+
"sha512": "56d4b780eb2b6164377db2d9756e9d1d6872436d2313f75a77b4ffce8be47d92c2fc502cc87369554a595d1844763bdb6ce3d14dc68ef849379070a259f920f3",
|
|
82
|
+
"sha256": "25644f10378a71e515dcfe1df64fb41fef0862fdfbe9cf52ac91675939cd76fb",
|
|
83
|
+
"sha1": "91a70d10d282ea3c01290747edd6b4f19226ad65",
|
|
84
|
+
"md5": "5af511777ab5671351368ebf881eb54b"
|
|
85
85
|
}
|
|
86
86
|
]
|
|
87
87
|
},
|
|
@@ -153,13 +153,13 @@
|
|
|
153
153
|
],
|
|
154
154
|
"files": [
|
|
155
155
|
{
|
|
156
|
-
"name": "expo.modules.filesystem-19.0.
|
|
157
|
-
"url": "expo.modules.filesystem-19.0.
|
|
158
|
-
"size":
|
|
159
|
-
"sha512": "
|
|
160
|
-
"sha256": "
|
|
161
|
-
"sha1": "
|
|
162
|
-
"md5": "
|
|
156
|
+
"name": "expo.modules.filesystem-19.0.8.aar",
|
|
157
|
+
"url": "expo.modules.filesystem-19.0.8.aar",
|
|
158
|
+
"size": 386221,
|
|
159
|
+
"sha512": "56d4b780eb2b6164377db2d9756e9d1d6872436d2313f75a77b4ffce8be47d92c2fc502cc87369554a595d1844763bdb6ce3d14dc68ef849379070a259f920f3",
|
|
160
|
+
"sha256": "25644f10378a71e515dcfe1df64fb41fef0862fdfbe9cf52ac91675939cd76fb",
|
|
161
|
+
"sha1": "91a70d10d282ea3c01290747edd6b4f19226ad65",
|
|
162
|
+
"md5": "5af511777ab5671351368ebf881eb54b"
|
|
163
163
|
}
|
|
164
164
|
]
|
|
165
165
|
},
|
|
@@ -173,13 +173,13 @@
|
|
|
173
173
|
},
|
|
174
174
|
"files": [
|
|
175
175
|
{
|
|
176
|
-
"name": "expo.modules.filesystem-19.0.
|
|
177
|
-
"url": "expo.modules.filesystem-19.0.
|
|
178
|
-
"size":
|
|
179
|
-
"sha512": "
|
|
180
|
-
"sha256": "
|
|
181
|
-
"sha1": "
|
|
182
|
-
"md5": "
|
|
176
|
+
"name": "expo.modules.filesystem-19.0.8-sources.jar",
|
|
177
|
+
"url": "expo.modules.filesystem-19.0.8-sources.jar",
|
|
178
|
+
"size": 28550,
|
|
179
|
+
"sha512": "b8f0a84aa8f6377f6fb162699e663d8e9de63caff453a37513e1cfeeaaa050261f8ae32032f15e8968e8591d518531d46e8e549c745b2998ee16fc7578903872",
|
|
180
|
+
"sha256": "267e88a3c5d6745c834050282f9a45c0305f51c7b8554e18e0b68a16ab337edb",
|
|
181
|
+
"sha1": "1c9d91c71b0534cc4967a352ccb7864aa71054c1",
|
|
182
|
+
"md5": "792cb40c62c2c908a410b672981f14b0"
|
|
183
183
|
}
|
|
184
184
|
]
|
|
185
185
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
910772c14e4d377fdf880d1f14683815
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
edf18906655a9e36799a9fd7a4a0a0504d80c7b4
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
42270c63b7df7a7e5d137d6c77f95b0a8a2aaa33325e69c7b4426caf00a21e8c
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
7ac666d194796a12dc4fcb504841bd4f1aa9073e73f8c6166fe35d3679ae078e1ae857a94f9f3285abfb042ef69c051dcfd81aa1f1ed5311e9f4cf9493a90a59
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<modelVersion>4.0.0</modelVersion>
|
|
10
10
|
<groupId>host.exp.exponent</groupId>
|
|
11
11
|
<artifactId>expo.modules.filesystem</artifactId>
|
|
12
|
-
<version>19.0.
|
|
12
|
+
<version>19.0.8</version>
|
|
13
13
|
<packaging>aar</packaging>
|
|
14
14
|
<name>expo.modules.filesystem</name>
|
|
15
15
|
<url>https://github.com/expo/expo</url>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
bcf64ce87633dbe2a6143eea0ca47bb9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
13ef2346544744def69586053a19731cfb269b18
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
602db45c912619293ac6cf4d840554e6269d8572329dde7f5af51d6d1174a883
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ec765be6812ea03216616a6ed18c3b28ce4f4d8f60fa8c6400c629204426074fc9373ffd65290d8f3f735408401fe47e140fd2754aebcd0a3729f57f82839bd0
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
<groupId>host.exp.exponent</groupId>
|
|
4
4
|
<artifactId>expo.modules.filesystem</artifactId>
|
|
5
5
|
<versioning>
|
|
6
|
-
<latest>19.0.
|
|
7
|
-
<release>19.0.
|
|
6
|
+
<latest>19.0.8</latest>
|
|
7
|
+
<release>19.0.8</release>
|
|
8
8
|
<versions>
|
|
9
|
-
<version>19.0.
|
|
9
|
+
<version>19.0.8</version>
|
|
10
10
|
</versions>
|
|
11
|
-
<lastUpdated>
|
|
11
|
+
<lastUpdated>20250902175113</lastUpdated>
|
|
12
12
|
</versioning>
|
|
13
13
|
</metadata>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
42876019a2c534b254bcc519820b1a83
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
eeba47e1c3b9979298a9ff3e5f5e21a0721a16dc
|
package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/maven-metadata.xml.sha256
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
6d9ade77b228fbce494829fbc4a09a437b07cbc2bb89011bf3a84c349a4749fa
|
package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/maven-metadata.xml.sha512
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
34e81020fc62cdc3e7d46321907a3f51b3802e95dd3716f63f2863237708f41c9c3b79c26cd14ba1cd8d9bb4cde63aa24d8cfa54299d6c330b494f1454a596d2
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-file-system",
|
|
3
|
-
"version": "19.0.
|
|
3
|
+
"version": "19.0.8",
|
|
4
4
|
"description": "Provides access to the local file system on the device.",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
"preset": "expo-module-scripts"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"expo-module-scripts": "^5.0.
|
|
39
|
-
"jest-expo": "~54.0.
|
|
38
|
+
"expo-module-scripts": "^5.0.6",
|
|
39
|
+
"jest-expo": "~54.0.7"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"expo": "*",
|
|
43
43
|
"react-native": "*"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "d635404a12ea7996b987ce0fb7679a238ebcf31b"
|
|
46
46
|
}
|
|
@@ -1,16 +1,39 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type FileCreateOptions = {
|
|
2
2
|
/**
|
|
3
3
|
* Whether to create intermediate directories if they do not exist.
|
|
4
4
|
* @default false
|
|
5
5
|
*/
|
|
6
6
|
intermediates?: boolean;
|
|
7
7
|
/**
|
|
8
|
-
* Whether to overwrite the file
|
|
8
|
+
* Whether to overwrite the file if it exists.
|
|
9
9
|
* @default false
|
|
10
10
|
*/
|
|
11
11
|
overwrite?: boolean;
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
+
export type DirectoryCreateOptions = {
|
|
15
|
+
/**
|
|
16
|
+
* Whether to create intermediate directories if they do not exist.
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
19
|
+
intermediates?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Whether to overwrite the directory if it exists.
|
|
22
|
+
* @default false
|
|
23
|
+
*/
|
|
24
|
+
overwrite?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* This flag controls whether the `create` operation is idempotent
|
|
27
|
+
* (safe to call multiple times without error).
|
|
28
|
+
*
|
|
29
|
+
* If `true`, creating a file or directory that already exists will succeed silently.
|
|
30
|
+
* If `false`, an error will be thrown when the target already exists.
|
|
31
|
+
*
|
|
32
|
+
* @default false
|
|
33
|
+
*/
|
|
34
|
+
idempotent?: boolean;
|
|
35
|
+
};
|
|
36
|
+
|
|
14
37
|
export declare class Directory {
|
|
15
38
|
/**
|
|
16
39
|
* Creates an instance of a directory.
|
|
@@ -48,9 +71,9 @@ export declare class Directory {
|
|
|
48
71
|
/**
|
|
49
72
|
* Creates a directory that the current uri points to.
|
|
50
73
|
*
|
|
51
|
-
* @throws Error if the containing folder doesn't exist, the application has no read access to it or the directory (or a file with the same path) already exists.
|
|
74
|
+
* @throws Error if the containing folder doesn't exist, the application has no read access to it or the directory (or a file with the same path) already exists (unless `idempotent` is `true`).
|
|
52
75
|
*/
|
|
53
|
-
create(options?:
|
|
76
|
+
create(options?: DirectoryCreateOptions): void;
|
|
54
77
|
|
|
55
78
|
createFile(name: string, mimeType: string | null): File;
|
|
56
79
|
|
|
@@ -66,6 +89,11 @@ export declare class Directory {
|
|
|
66
89
|
*/
|
|
67
90
|
move(destination: Directory | File): void;
|
|
68
91
|
|
|
92
|
+
/**
|
|
93
|
+
* Renames a directory.
|
|
94
|
+
*/
|
|
95
|
+
rename(newName: string): void;
|
|
96
|
+
|
|
69
97
|
/**
|
|
70
98
|
* @hidden
|
|
71
99
|
* Lists the contents of a directory. Should not be used directly, as it returns a list of paths.
|
|
@@ -199,7 +227,7 @@ export declare class File {
|
|
|
199
227
|
*
|
|
200
228
|
* @throws Error if the containing folder doesn't exist, the application has no read access to it or the file (or directory with the same path) already exists.
|
|
201
229
|
*/
|
|
202
|
-
create(options?:
|
|
230
|
+
create(options?: FileCreateOptions): void;
|
|
203
231
|
|
|
204
232
|
/**
|
|
205
233
|
* Copies a file.
|
|
@@ -211,6 +239,11 @@ export declare class File {
|
|
|
211
239
|
*/
|
|
212
240
|
move(destination: Directory | File): void;
|
|
213
241
|
|
|
242
|
+
/**
|
|
243
|
+
* Renames a file.
|
|
244
|
+
*/
|
|
245
|
+
rename(newName: string): void;
|
|
246
|
+
|
|
214
247
|
/**
|
|
215
248
|
* Returns A `FileHandle` object that can be used to read and write data to the file.
|
|
216
249
|
* @throws Error if the file does not exist or cannot be opened.
|
|
@@ -237,16 +270,15 @@ export declare class File {
|
|
|
237
270
|
): Promise<File>;
|
|
238
271
|
|
|
239
272
|
/**
|
|
240
|
-
* A static method that opens a file picker to select a single file of specified type.
|
|
273
|
+
* A static method that opens a file picker to select a single file of specified type. On iOS, it returns a temporary copy of the file leaving the original file untouched.
|
|
241
274
|
*
|
|
242
|
-
*
|
|
275
|
+
* Selecting multiple files is not supported yet.
|
|
243
276
|
*
|
|
244
277
|
* @param initialUri An optional URI pointing to an initial folder on which the file picker is opened.
|
|
245
278
|
* @param mimeType A mime type that is used to filter out files that can be picked out.
|
|
246
|
-
* @returns a `File` instance.
|
|
247
|
-
* @platform android
|
|
279
|
+
* @returns a `File` instance or an array of `File` instances.
|
|
248
280
|
*/
|
|
249
|
-
static pickFileAsync(initialUri?: string, mimeType?: string): Promise<File>;
|
|
281
|
+
static pickFileAsync(initialUri?: string, mimeType?: string): Promise<File | File[]>;
|
|
250
282
|
|
|
251
283
|
/**
|
|
252
284
|
* A size of the file in bytes. 0 if the file does not exist, or it cannot be read.
|
package/src/index.ts
CHANGED
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
8e4953080a31fa4851c0d3af21f5f2a8
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
5f879a11258f3b3e06b575f71e801aab8e25113b
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
9cf826cfa827700e415e780bc1b4a49477ea31486d465154824b7331c89e9dc7
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
c91977ae610fa808ea0765cd14182ad1d8961f59cbdf2df2396e7f77fe8cadbcd152018902a4f09474177b5ea77f78c107d6016c127d0546c4e9b0ebbf2b13fe
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
67fb8fe6d438a03c9f9b1419f17a116d
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
7f26aacfe041259700988a8f2e865b6d78a47865
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
977ef17ccaa7a6f8c09c70d2f2f2f0c1002f07df8b3756ce3905a37a7288b41b
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
36dc7ab692103570111d72588e7674ae1c7cf2c0665a351738f87dc0af98dbccb34aef221f34b5630403f2d6fd46a13cd22e4b3fb75a90f6b8b0bc2a41dd49cf
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
7a30c0dd94620ad6d4b349c4768849cf
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
244290223c70f2fa559e6ac33637b48d5a8fe030
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
30cd879db3d67a93bbb86483e0e47f54a109f1e4dfbb33c2726401c737503b44
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
d901e0bd5c6391eb748e76ad90a69263c236f8c87d1e8e23b5852d09803e4db69e96b909177165c6869b3d0decc843e1daab4d61a93fa17bda56964588e9545b
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
abff231e2fb99adbfde79370e6fa1395
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
018d4dbaa67ec3eb39fb639ef68e39a06d303ad7
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
fa1bdccedadabacbd2a0c6bc51aa70233255f74486b3c6b99e99829e58973760
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
91daccf5e4bfef06a91de0573936e5d637bd29472ece40112290d9cc5d65bc545d8adc3070662fefc4140d51eeddc09b6ff64b5403476a1c750cfb173273f6bd
|