Browse Source

Merge pull request #319 from alpha0010/ios-fs-dirs

Fix fs.dirs api on iOS
Travis Nuttall 5 years ago
parent
commit
df81a14872
No account linked to committer's email address
3 changed files with 22 additions and 4 deletions
  1. 7
    2
      ios/RNFetchBlob/RNFetchBlob.m
  2. 7
    2
      ios/RNFetchBlobFS.h
  3. 8
    0
      ios/RNFetchBlobFS.m

+ 7
- 2
ios/RNFetchBlob/RNFetchBlob.m View File

@@ -68,9 +68,14 @@ RCT_EXPORT_MODULE();
68 68
 - (NSDictionary *)constantsToExport
69 69
 {
70 70
     return @{
71
-             @"MainBundleDir" : [RNFetchBlobFS getMainBundleDir],
71
+             @"CacheDir" : [RNFetchBlobFS getCacheDir],
72 72
              @"DocumentDir": [RNFetchBlobFS getDocumentDir],
73
-             @"CacheDir" : [RNFetchBlobFS getCacheDir]
73
+             @"DownloadDir" : [RNFetchBlobFS getDownloadDir],
74
+             @"LibraryDir" : [RNFetchBlobFS getLibraryDir],
75
+             @"MainBundleDir" : [RNFetchBlobFS getMainBundleDir],
76
+             @"MovieDir" : [RNFetchBlobFS getMovieDir],
77
+             @"MusicDir" : [RNFetchBlobFS getMusicDir],
78
+             @"PictureDir" : [RNFetchBlobFS getPictureDir],
74 79
              };
75 80
 }
76 81
 

+ 7
- 2
ios/RNFetchBlobFS.h View File

@@ -46,10 +46,15 @@
46 46
 @property (nonatomic) BOOL appendData;
47 47
 
48 48
 // get dirs
49
-+ (NSString *) getMainBundleDir;
50
-+ (NSString *) getTempPath;
51 49
 + (NSString *) getCacheDir;
52 50
 + (NSString *) getDocumentDir;
51
++ (NSString *) getDownloadDir;
52
++ (NSString *) getLibraryDir;
53
++ (NSString *) getMainBundleDir;
54
++ (NSString *) getMovieDir;
55
++ (NSString *) getMusicDir;
56
++ (NSString *) getPictureDir;
57
++ (NSString *) getTempPath;
53 58
 + (NSString *) getTempPath:(NSString*)taskId withExtension:(NSString *)ext;
54 59
 + (NSString *) getPathOfAsset:(NSString *)assetURI;
55 60
 + (NSString *) getPathForAppGroup:(NSString *)groupName;

+ 8
- 0
ios/RNFetchBlobFS.m View File

@@ -104,6 +104,14 @@ NSMutableDictionary *fileStreams = nil;
104 104
     return [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject];
105 105
 }
106 106
 
107
++ (NSString *) getDownloadDir {
108
+    return [NSSearchPathForDirectoriesInDomains(NSDownloadsDirectory, NSUserDomainMask, YES) firstObject];
109
+}
110
+
111
++ (NSString *) getLibraryDir {
112
+    return [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) firstObject];
113
+}
114
+
107 115
 + (NSString *) getMusicDir {
108 116
     return [NSSearchPathForDirectoriesInDomains(NSMusicDirectory, NSUserDomainMask, YES) firstObject];
109 117
 }