Clean folders and files from the Processing subdirectory of the user's temp folder (java.io.tmpdir).
()
| 410 | * of the user's temp folder (java.io.tmpdir). |
| 411 | */ |
| 412 | static public void cleanTempFolders() { |
| 413 | try { |
| 414 | final File tempDir = Util.getProcessingTemp(); |
| 415 | final int days = Preferences.getInteger("temp.days"); |
| 416 | |
| 417 | if (days > 0) { |
| 418 | final long now = new Date().getTime(); |
| 419 | final long diff = days * 24 * 60 * 60 * 1000L; |
| 420 | File[] expiredFiles = |
| 421 | tempDir.listFiles(file -> (now - file.lastModified()) > diff); |
| 422 | if (expiredFiles != null) { |
| 423 | // Remove the files approved for deletion |
| 424 | for (File file : expiredFiles) { |
| 425 | try { |
| 426 | // move to trash or delete if unavailable |
| 427 | Platform.deleteFile(file); |
| 428 | } catch (IOException e) { |
| 429 | e.printStackTrace(); |
| 430 | } |
| 431 | } |
| 432 | } |
| 433 | } |
| 434 | } catch (IOException e) { |
| 435 | e.printStackTrace(); |
| 436 | } |
| 437 | } |
| 438 | |
| 439 | |
| 440 | // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
no test coverage detected