1 | static int deleteAllFilesInDirectory_minPathLength = 10; |
2 | |
3 | static void deleteAllFilesInDirectory(File dir) { |
4 | deleteAllFilesInDirectory(dir, false, false); |
5 | } |
6 | |
7 | static void deleteAllFilesInDirectory(File dir, boolean verbose, boolean testRun) { |
8 | dir = getCanonicalFile(dir); |
9 | assertTrue(f2s(dir), l(f2s(dir)) >= deleteAllFilesInDirectory_minPathLength); |
10 | File[] files = dir.listFiles(); |
11 | if (files == null) return; |
12 | for (File f : files) { |
13 | if (!isSymLink(f) && f.isDirectory()) // just delete the symlink, don't follow it |
14 | deleteDirectory(f, verbose, testRun); |
15 | else { |
16 | if (verbose) |
17 | print((testRun ? "Would delete " : "Deleting ") + f.getAbsolutePath()); |
18 | if (!testRun) |
19 | f.delete(); |
20 | } |
21 | } |
22 | } |
Began life as a copy of #1001058
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1018389 |
Snippet name: | deleteAllFilesInDirectory (dangerous :)) |
Eternal ID of this version: | #1018389/3 |
Text MD5: | 394e1d47d221fc46c584d17ad03b0ab0 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-12-13 15:37:51 |
Source code size: | 756 bytes / 22 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 421 / 463 |
Version history: | 2 change(s) |
Referenced in: | [show references] |