|
@@ -412,13 +412,24 @@ public class RNFetchBlobFS {
|
412
|
412
|
*/
|
413
|
413
|
static void unlink(String path, Callback callback) {
|
414
|
414
|
try {
|
415
|
|
- boolean success = new File(path).delete();
|
416
|
|
- callback.invoke( null, success);
|
|
415
|
+ RNFetchBlobFS.deleteRecursive(new File(path));
|
|
416
|
+ callback.invoke(null, true);
|
417
|
417
|
} catch(Exception err) {
|
418
|
418
|
if(err != null)
|
419
|
|
- callback.invoke(err.getLocalizedMessage());
|
|
419
|
+ callback.invoke(err.getLocalizedMessage(), false);
|
420
|
420
|
}
|
421
|
421
|
}
|
|
422
|
+
|
|
423
|
+ static void deleteRecursive(File fileOrDirectory) {
|
|
424
|
+
|
|
425
|
+ if (fileOrDirectory.isDirectory()) {
|
|
426
|
+ for (File child : fileOrDirectory.listFiles()) {
|
|
427
|
+ deleteRecursive(child);
|
|
428
|
+ }
|
|
429
|
+ }
|
|
430
|
+ fileOrDirectory.delete();
|
|
431
|
+ }
|
|
432
|
+
|
422
|
433
|
/**
|
423
|
434
|
* Make a folder
|
424
|
435
|
* @param path Source path
|