use of com.capacitorjs.plugins.filesystem.exceptions.DirectoryNotFoundException in project capacitor-plugins by ionic-team.
the class FilesystemPlugin method readdir.
@PluginMethod
public void readdir(PluginCall call) {
String path = call.getString("path");
String directory = getDirectoryParameter(call);
if (isPublicDirectory(directory) && !isStoragePermissionGranted()) {
requestAllPermissions(call, "permissionCallback");
} else {
try {
String[] files = implementation.readdir(path, directory);
if (files != null) {
JSObject ret = new JSObject();
ret.put("files", JSArray.from(files));
call.resolve(ret);
} else {
call.reject("Unable to read directory");
}
} catch (DirectoryNotFoundException ex) {
call.reject(ex.getMessage());
}
}
}
Aggregations