From 12ce96d8026004e72cb6abf94fc98c8d76e43bcc Mon Sep 17 00:00:00 2001 From: Jeremy Long Date: Wed, 28 Aug 2013 06:15:24 -0400 Subject: [PATCH] updated getFile to correctly get the main data directory Former-commit-id: 4c175b6c218c264c8255614858545224c0c597f7 --- .../owasp/dependencycheck/utils/Settings.java | 30 +++++-------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/utils/Settings.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/utils/Settings.java index 3a60bf6f2..bc48db645 100644 --- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/utils/Settings.java +++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/utils/Settings.java @@ -226,25 +226,6 @@ public final class Settings { INSTANCE.props.load(stream); } - /** - * Returns a value from the properties file as a File object. If the value - * was specified as a system property or passed in via the -Dprop=value - * argument - this method will return the value from the system properties - * before the values in the contained configuration file. - * - * @param key the key to lookup within the properties file - * @param defaultValue the default value for the requested property - * @return the property from the properties file as a File object - */ - public static File getFile(String key, String defaultValue) { - final String baseDir = getString(Settings.KEYS.DATA_DIRECTORY); - final String str = getString(key, defaultValue); - if (baseDir != null) { - return new File(baseDir, str); - } - return new File(str); - } - /** * Returns a value from the properties file as a File object. If the value * was specified as a system property or passed in via the -Dprop=value @@ -256,17 +237,22 @@ public final class Settings { * * @param key the key to lookup within the properties file * @return the property from the properties file converted to a File object - * @throws IOException thrown if the file path to the JAR cannot be found */ - public static File getFile(String key) throws IOException { + public static File getFile(String key) { final String file = getString(key); final String baseDir = getString(Settings.KEYS.DATA_DIRECTORY); if (baseDir != null) { if (baseDir.startsWith("[JAR]/")) { final File jarPath = getJarPath(); - final File newBase = new File(jarPath.getCanonicalPath(), baseDir.substring(6)); + final File newBase = new File(jarPath, baseDir.substring(6)); + if (Settings.KEYS.DATA_DIRECTORY.equals(key)) { + return newBase; + } return new File(newBase, file); } + if (Settings.KEYS.DATA_DIRECTORY.equals(key)) { + return new File(baseDir); + } return new File(baseDir, file); } return new File(file);