mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-03-20 16:24:11 +01:00
updated getFile to correctly get the main data directory
Former-commit-id: 5c103099848de6d452c300f9c57c22795c63bf2c
This commit is contained in:
@@ -226,25 +226,6 @@ public final class Settings {
|
|||||||
INSTANCE.props.load(stream);
|
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
|
* 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
|
* 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
|
* @param key the key to lookup within the properties file
|
||||||
* @return the property from the properties file converted to a File object
|
* @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 file = getString(key);
|
||||||
final String baseDir = getString(Settings.KEYS.DATA_DIRECTORY);
|
final String baseDir = getString(Settings.KEYS.DATA_DIRECTORY);
|
||||||
if (baseDir != null) {
|
if (baseDir != null) {
|
||||||
if (baseDir.startsWith("[JAR]/")) {
|
if (baseDir.startsWith("[JAR]/")) {
|
||||||
final File jarPath = getJarPath();
|
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);
|
return new File(newBase, file);
|
||||||
}
|
}
|
||||||
|
if (Settings.KEYS.DATA_DIRECTORY.equals(key)) {
|
||||||
|
return new File(baseDir);
|
||||||
|
}
|
||||||
return new File(baseDir, file);
|
return new File(baseDir, file);
|
||||||
}
|
}
|
||||||
return new File(file);
|
return new File(file);
|
||||||
|
|||||||
Reference in New Issue
Block a user