(String filename, boolean createOnDemand)
| 31 | public PluginList() { |
| 32 | Parser.Config.Builder builder = Parsers.newParserConfigBuilder(); |
| 33 | parser = Parsers.newParser(builder.build()); |
| 34 | } |
| 35 | |
| 36 | public Map<String, List<Object>> read(String filename, boolean createOnDemand) throws IOException { |
| 37 | |
| 38 | try { |
| 39 | if (!new File(filename).exists()) { |
| 40 | if (createOnDemand) createBlankFile(filename); |
| 41 | return Collections.emptyMap(); |
| 42 | } |
| 43 | |
| 44 | try (FileReader fr = new FileReader(new File(filename))) { |
| 45 | Parseable parseme = Parsers.newParseable(fr); |
| 46 | |
| 47 | Map<String, List<Object>> r = new LinkedHashMap<>(); |
| 48 | |
| 49 | while (true) { |
| 50 | Object o = parser.nextValue(parseme); |
| 51 | if (o.equals(Parser.END_OF_INPUT)) break; |
| 52 | |
| 53 | massageAndCollapse(o, r); |
| 54 | } |
| 55 | return r; |
| 56 | } |
| 57 | } |
| 58 | catch(EdnSyntaxException syntax) |
| 59 | { |
| 60 | syntax.printStackTrace(); |
| 61 | Log.log("startup.error", ()->"Syntax error in plugins.edn file "+syntax+" "+filename); |
| 62 | return null; |
no test coverage detected