Opens the configuration file ("plugins.config") from a JAR file and returns it as an InputStream.
(String jar)
| 1006 | |
| 1007 | /** Opens the configuration file ("plugins.config") from a JAR file and returns it as an InputStream. */ |
| 1008 | InputStream getConfigurationFile(String jar) { |
| 1009 | try { |
| 1010 | ZipFile jarFile = new ZipFile(jar); |
| 1011 | Enumeration entries = jarFile.entries(); |
| 1012 | while (entries.hasMoreElements()) { |
| 1013 | ZipEntry entry = (ZipEntry) entries.nextElement(); |
| 1014 | if (entry.getName().endsWith("plugins.config")) |
| 1015 | return jarFile.getInputStream(entry); |
| 1016 | } |
| 1017 | jarFile.close(); |
| 1018 | } |
| 1019 | catch (Throwable e) { |
| 1020 | IJ.log(jar+": "+e); |
| 1021 | } |
| 1022 | return autoGenerateConfigFile(jar); |
| 1023 | } |
| 1024 | |
| 1025 | /** Creates a configuration file for JAR/ZIP files that do not have one. */ |
| 1026 | InputStream autoGenerateConfigFile(String jar) { |
no test coverage detected