blob: d31d3a8fba05d6cd67bd042d20d01bca34d0ec23 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
package dslog;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
public class LogDir {
private static LogSet getSet(Map<String, LogSet> sets, String filename) {
String setname = filename.substring(0, filename.lastIndexOf('.'));
LogSet set;
set = sets.get(setname);
if (set == null) {
set = new LogSet(setname);
sets.put(set.name, set);
}
return set;
}
public static SortedMap<String, LogSet> opendir(String dirname) throws IOException {
SortedMap<String, LogSet> logsets = new TreeMap<String, LogSet>();
List<Exception> errs = new ArrayList<Exception>();
Files.list(Paths.get(dirname)).forEach(filepath->{
String filename = filepath.getFileName().toString();
if (filename.endsWith(".dslog")) {
getSet(logsets, filename).dslogPath = filepath;
} else if (filename.endsWith(".dsevents")) {
getSet(logsets, filename).dseventsPath = filepath;
} else if (filename.endsWith(".pdplog")) {
getSet(logsets, filename).pdplogPath = filepath;
}
});
return logsets;
}
}
|