()
| 122 | |
| 123 | |
| 124 | static public void cleanTempFiles() { |
| 125 | final File consoleDir = Base.getSettingsFile("console"); |
| 126 | final int days = Preferences.getInteger("console.temp.days"); |
| 127 | |
| 128 | if (days > 0) { |
| 129 | final long now = new Date().getTime(); |
| 130 | final long diff = days * 24 * 60 * 60 * 1000L; |
| 131 | File[] expiredFiles = consoleDir.listFiles(file -> { |
| 132 | if (!file.isDirectory()) { |
| 133 | String name = file.getName(); |
| 134 | // Not really |
| 135 | if (name.endsWith(".err") || name.endsWith(".out")) { |
| 136 | return now - file.lastModified() > diff; |
| 137 | } |
| 138 | } |
| 139 | return false; |
| 140 | }); |
| 141 | // Remove the files approved for deletion |
| 142 | for (File file : expiredFiles) { |
| 143 | //file.delete(); // not as safe |
| 144 | try { |
| 145 | Platform.deleteFile(file); // move to trash |
| 146 | } catch (IOException e) { |
| 147 | e.printStackTrace(); |
| 148 | } |
| 149 | } |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | |
| 154 | static public void setEditor(OutputStream out, OutputStream err) { |
no test coverage detected