/*
- * jSite - ConfigurationLocator.java - Copyright © 2011 David Roden
+ * jSite - ConfigurationLocator.java - Copyright © 2011–2012 David Roden
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/**
* Creates a new configuration locator. If this class is loaded from a JAR
- * file, {@link ConfigurationLocation#NEXT_TO_JAR_FILE} is added to the
- * list of possible configuration file locations.
+ * file, {@link ConfigurationLocation#NEXT_TO_JAR_FILE} is added to the list
+ * of possible configuration file locations.
* {@link ConfigurationLocation#HOME_DIRECTORY} is always added to this
* list, {@link ConfigurationLocation#CUSTOM} has to be enabled by calling
* {@link #setCustomLocation(String)}.
/**
* Returns whether the given location is valid. Certain locations (such as
- * {@link ConfigurationLocation#NEXT_TO_JAR_FILE}) may be invalid in
- * certain circumstances (such as the application not being run from a JAR
- * file). A location being valid does not imply that a configuration file
- * does exist at the given location, use
- * {@link #hasFile(ConfigurationLocation)} to check for a configuration
- * file at the desired location.
+ * {@link ConfigurationLocation#NEXT_TO_JAR_FILE}) may be invalid in certain
+ * circumstances (such as the application not being run from a JAR file). A
+ * location being valid does not imply that a configuration file does exist
+ * at the given location, use {@link #hasFile(ConfigurationLocation)} to
+ * check for a configuration file at the desired location.
*
* @param configurationLocation
* The configuration location
if (hasFile(ConfigurationLocation.HOME_DIRECTORY)) {
return ConfigurationLocation.HOME_DIRECTORY;
}
- return defaultLocation;
+ if (isValidLocation(defaultLocation)) {
+ return defaultLocation;
+ }
+ return ConfigurationLocation.HOME_DIRECTORY;
}
}