diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2017-03-14 00:46:04 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2017-03-14 00:46:04 -0400 |
commit | 17365c1bf397423e4973f5b431bea44bf199076a (patch) | |
tree | d4f7cd051b3a1630b1fc1be2be6a6cf2495c3b1f /dslog/LogDir.java | |
parent | aced3e4562b3feac81a11e392ede8b1b30c40345 (diff) |
match identification
Diffstat (limited to 'dslog/LogDir.java')
-rw-r--r-- | dslog/LogDir.java | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/dslog/LogDir.java b/dslog/LogDir.java new file mode 100644 index 0000000..d31d3a8 --- /dev/null +++ b/dslog/LogDir.java @@ -0,0 +1,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; + } +} |