Merge branch 'master' of https://github.com/ngrj/react-native-fs into ngrj-master

* 'master' of https://github.com/ngrj/react-native-fs:
  added a function called getAllExternalFilesDirs to get application-specific directories on all shared/external storage devices
This commit is contained in:
Hagen Hübel 2017-12-10 14:52:17 +01:00
commit fd39484c75
3 changed files with 18 additions and 0 deletions

View File

@ -201,6 +201,10 @@ var RNFS = {
return RNFSManager.getFSInfo();
},
getAllExternalFilesDirs(): Promise<FSInfoResult> {
return RNFSManager.getAllExternalFilesDirs();
},
unlink(filepath: string): Promise<void> {
return RNFSManager.unlink(normalizeFilePath(filepath)).then(() => void 0);
},

View File

@ -654,6 +654,10 @@ type FSInfoResult = {
};
```
### `getAllExternalFilesDirs(): Promise<ExternalFilesDirs>`
Returns an array with the absolute paths to application-specific directories on all shared/external storage devices where the application can place persistent files it owns.
### (iOS only) `pathForGroup(groupIdentifier: string): Promise<string>`
`groupIdentifier` (`string`) Any value from the *com.apple.security.application-groups* entitlements list.

View File

@ -706,6 +706,16 @@ public class RNFSManager extends ReactContextBaseJavaModule {
}
}
@ReactMethod
public void getAllExternalFilesDirs(Promise promise){
File[] allExternalFilesDirs = this.getReactApplicationContext().getExternalFilesDirs(null);
WritableArray fs = Arguments.createArray();
for (File f : allExternalFilesDirs) {
fs.pushString(f.getAbsolutePath());
}
promise.resolve(fs);
}
private void reject(Promise promise, String filepath, Exception ex) {
if (ex instanceof FileNotFoundException) {
rejectFileNotFound(promise, filepath);