MCPcopy Index your code
hub / github.com/benfry/processing4 / cleanTempFiles

Method cleanTempFiles

app/src/processing/app/Console.java:124–151  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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) {

Callers 1

handleTempCleaningMethod · 0.95

Calls 7

getSettingsFileMethod · 0.95
getIntegerMethod · 0.95
deleteFileMethod · 0.95
getTimeMethod · 0.80
listFilesMethod · 0.45
getNameMethod · 0.45
printStackTraceMethod · 0.45

Tested by

no test coverage detected