public String getPerUserPluginDirectoryName() { String name; if (pluginDir == null) { name = getPluginID(); } else { name = new File(pluginDir).getName(); } String str = new File(new File(SystemProperties.getUserPath(), "plugins"), name).getAbsolutePath(); if (pluginDir == null) { return (str); } try { if (new File(pluginDir).getCanonicalPath().equals(new File(str).getCanonicalPath())) { return (pluginDir); } } catch (Throwable e) { } return (str); }
private void exportParameters() { synchronized (exported_parameters) { if (!exported_parameters_dirty) { return; } exported_parameters_dirty = false; try { TreeMap<String, String> tm = new TreeMap<String, String>(); Set<String> exported_keys = new HashSet<String>(); for (String[] entry : exported_parameters.values()) { String key = entry[0]; String value = entry[1]; exported_keys.add(key); if (value != null) { tm.put(key, value); } } for (Map.Entry<String, String> entry : imported_parameters.entrySet()) { String key = entry.getKey(); if (!exported_keys.contains(key)) { tm.put(key, entry.getValue()); } } File parent_dir = new File(SystemProperties.getUserPath()); File props = new File(parent_dir, "exported_params.properties"); PrintWriter pw = new PrintWriter(new OutputStreamWriter(new FileOutputStream(props), "UTF-8")); try { for (Map.Entry<String, String> entry : tm.entrySet()) { pw.println(entry.getKey() + "=" + entry.getValue()); } } finally { pw.close(); } } catch (Throwable e) { e.printStackTrace(); } } }
private void loadExportedParameters() { synchronized (exported_parameters) { try { File parent_dir = new File(SystemProperties.getUserPath()); File props = new File(parent_dir, "exported_params.properties"); if (props.exists()) { LineNumberReader lnr = new LineNumberReader(new InputStreamReader(new FileInputStream(props), "UTF-8")); try { while (true) { String line = lnr.readLine(); if (line == null) { break; } String[] bits = line.split("="); if (bits.length == 2) { String key = bits[0].trim(); String value = bits[1].trim(); if (key.length() > 0 && value.length() > 0) { imported_parameters.put(key, value); } } } } finally { lnr.close(); } } } catch (Throwable e) { e.printStackTrace(); } } COConfigurationManager.setIntDefault("instance.port", Constants.INSTANCE_PORT); registerExportedParameter("instance.port", "instance.port"); }
protected File getDevicesDir() throws IOException { File dir = new File(SystemProperties.getUserPath()); dir = new File(dir, "devices"); if (!dir.exists()) { if (!dir.mkdirs()) { throw (new IOException("Failed to create '" + dir + "'")); } } return (dir); }