|
@@ -22,44 +22,14 @@ import type {
|
22
|
22
|
|
23
|
23
|
const RNFetchBlob:RNFetchBlobNative = NativeModules.RNFetchBlob
|
24
|
24
|
const emitter = DeviceEventEmitter
|
25
|
|
-
|
26
|
|
-// session table
|
27
|
|
-let sessions = {}
|
28
|
|
-
|
29
|
|
-/**
|
30
|
|
- * Get path of system directories.
|
31
|
|
- * @return {object} Map contains DocumentDir, CacheDir, DCIMDir, DownloadDir,
|
32
|
|
- * , some directory might not be supported by platform.
|
33
|
|
- */
|
34
|
|
-function getSystemDirs() {
|
35
|
|
- return new Promise((resolve, reject) => {
|
36
|
|
- try {
|
37
|
|
- RNFetchBlob.getEnvironmentDirs((...dirs) => {
|
38
|
|
- let [
|
39
|
|
- DocumentDir,
|
40
|
|
- CacheDir,
|
41
|
|
- // Android only
|
42
|
|
- DCIMDir,
|
43
|
|
- DownloadDir,
|
44
|
|
- PictureDir,
|
45
|
|
- MusicDir,
|
46
|
|
- MovieDir,
|
47
|
|
- RingToneDir] = [...dirs]
|
48
|
|
- resolve({
|
49
|
|
- DocumentDir,
|
50
|
|
- CacheDir,
|
51
|
|
- DCIMDir,
|
52
|
|
- DownloadDir,
|
53
|
|
- PictureDir,
|
54
|
|
- MusicDir,
|
55
|
|
- MovieDir,
|
56
|
|
- RingToneDir
|
57
|
|
- })
|
58
|
|
- })
|
59
|
|
- } catch(err) {
|
60
|
|
- reject(err)
|
61
|
|
- }
|
62
|
|
- })
|
|
25
|
+const dirs = {
|
|
26
|
+ DocumentDir : RNFetchBlob.DocumentDir,
|
|
27
|
+ CacheDir : RNFetchBlob.CacheDir,
|
|
28
|
+ PictureDir : RNFetchBlob.PictureDir,
|
|
29
|
+ MusicDir : RNFetchBlob.MusicDir,
|
|
30
|
+ MovieDir : RNFetchBlob.MovieDir,
|
|
31
|
+ DownloadDir : RNFetchBlob.DownloadDir,
|
|
32
|
+ DCIMDir : RNFetchBlob.DCIMDir
|
63
|
33
|
}
|
64
|
34
|
|
65
|
35
|
/**
|
|
@@ -289,7 +259,6 @@ export default {
|
289
|
259
|
session,
|
290
|
260
|
ls,
|
291
|
261
|
readStream,
|
292
|
|
- getSystemDirs,
|
293
|
262
|
mv,
|
294
|
263
|
cp,
|
295
|
264
|
writeStream,
|
|
@@ -298,5 +267,6 @@ export default {
|
298
|
267
|
isDir,
|
299
|
268
|
stat,
|
300
|
269
|
lstat,
|
301
|
|
- scanFile
|
|
270
|
+ scanFile,
|
|
271
|
+ dirs
|
302
|
272
|
}
|