summaryrefslogtreecommitdiff
path: root/dslog/Logdir.java
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2017-03-14 00:46:04 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2017-03-14 00:46:04 -0400
commit17365c1bf397423e4973f5b431bea44bf199076a (patch)
treed4f7cd051b3a1630b1fc1be2be6a6cf2495c3b1f /dslog/Logdir.java
parentaced3e4562b3feac81a11e392ede8b1b30c40345 (diff)
match identification
Diffstat (limited to 'dslog/Logdir.java')
-rw-r--r--dslog/Logdir.java82
1 files changed, 0 insertions, 82 deletions
diff --git a/dslog/Logdir.java b/dslog/Logdir.java
deleted file mode 100644
index ea7683b..0000000
--- a/dslog/Logdir.java
+++ /dev/null
@@ -1,82 +0,0 @@
-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;
-import java.util.function.Supplier;
-
-class Logdir {
- public static class LogSet {
- public final String name;
- public LogSet(String name) {
- this.name = name;
- }
- public Path dslogPath, dseventsPath, pdplogPath;
-
- public String toString() {
- return name+" "+verstr(this::dslog)+"/"+verstr(this::dsevents)+"/"+verstr(this::pdplog);
- }
-
- private static String verstr(Versioned.Supplier getter) {
- try (Versioned thing = getter.get()) {
- if (thing == null) {
- return "␕";
- }
- return ""+thing.version();
- } catch (IOException e) {
- return "☠";
- }
- }
-
- public DslogReader dslog() throws IOException {
- if (dslogPath == null) {
- return null;
- }
- return new DslogReader(Files.newInputStream(dslogPath));
- }
- public DseventsReader dsevents() throws IOException {
- if (dseventsPath == null) {
- return null;
- }
- return new DseventsReader(Files.newInputStream(dseventsPath));
- }
- public PdplogReader pdplog() throws IOException {
- if (pdplogPath == null) {
- return null;
- }
- return new PdplogReader(Files.newInputStream(pdplogPath));
- }
- }
-
- 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;
- }
-}