148 |
|
|
149 |
|
// list the files and delete as appropriate |
150 |
|
File alertsDir = new File(rootPath, alertSubDir); |
151 |
+ |
// get all the hostnames directories |
152 |
|
File[] contents = alertsDir.listFiles(); |
153 |
|
for(int i=0; i < contents.length; i++) { |
154 |
+ |
// get a single directory from the array.. |
155 |
|
File hostdir = contents[i]; |
156 |
+ |
// ..and check it's a directory |
157 |
|
if(hostdir.isDirectory()) { |
158 |
+ |
// get all the contents of that directory |
159 |
|
File[] hostdirContents = hostdir.listFiles(); |
160 |
|
for(int j=0; j < hostdirContents.length; j++) { |
161 |
|
File alertFile = hostdirContents[j]; |
162 |
+ |
// get the filename.. |
163 |
|
String filename = alertFile.getName(); |
164 |
+ |
// ..and see if it ends with OK or FINAL |
165 |
|
if(filename.endsWith(Alert.alertLevels[0]) || |
166 |
|
filename.endsWith(Alert.alertLevels[Alert.alertLevels.length-1])) { |
167 |
< |
// it ends with either OK or FINAL |
167 |
> |
// it does end with either OK or FINAL |
168 |
|
// ... so we can check it for deletion |
169 |
|
long lastModified = alertFile.lastModified(); |
170 |
|
long age = System.currentTimeMillis() - lastModified; |