/** * Load the conf from a buffer. This is used to load conf entries from the cached mods.d.tar.gz or mods.d.zip file. * * @param buffer * the buffer to load * @throws IOException */ private void loadBuffer(byte[] buffer, Filter<String> keepers) throws IOException { filtered = keepers != null; configAll.clear(); configAll.load(buffer, ENCODING_UTF8, keepers); String encoding = configAll.get(KEY_ENCODING); if (!ENCODING_UTF8.equalsIgnoreCase(encoding)) { configAll.clear(); configAll.load(buffer, ENCODING_LATIN1, keepers); } }
/** * Load the conf from a file. * * @param keepers * the keys to keep. When null keep all * @throws IOException */ private void loadFile(Filter<String> keepers) throws IOException { filtered = keepers != null; configAll.clear(); configAll.load(configFile, ENCODING_UTF8, keepers); String encoding = configAll.get(KEY_ENCODING); if (!ENCODING_UTF8.equalsIgnoreCase(encoding)) { configAll.clear(); configAll.load(configFile, ENCODING_LATIN1, keepers); } }
public void parse() throws IOException { File confFile = new File(conf); if (!confFile.exists()) { System.err.println("File does not exist: " + conf); return; } IniSection config = new IniSection(); // So called Latin-1 is the default, but most are UTF-8 config.load(confFile, "UTF-8"); String encoding = config.get("Encoding"); if (encoding == null || "Latin-1".equalsIgnoreCase(encoding)) { config.clear(); config.load(confFile, "WINDOWS-1252"); } SwordBookMetaData.report(config); SwordBookMetaData.normalize(new PrintWriter(System.out), config, CANONICAL_ORDER); }
public void reload(Filter<String> keepers) throws BookException { // Always run if it is filtered // Always run if a filter is supplied // Do not run if it is already not filtered and no filter is supplied if (!filtered && keepers == null) { return; } this.supported = true; if (configJSword != null) { configJSword.clear(); } if (configFrontend != null) { configFrontend.clear(); } try { if (installed) { loadFile(keepers); } else { byte[] buffer = IOUtil.getZipEntry(bookConf); loadBuffer(buffer, keepers); } adjustConfig(); report(configAll); this.configJSword = addConfig(MetaDataLocator.JSWORD); this.configFrontend = addConfig(MetaDataLocator.FRONTEND); } catch (IOException ex) { throw new BookException("unable to load conf", ex); } }