*/
public static boolean addToDaemonConfig(File localDir) throws ConfigException {
File daemonConfigFile = new File(UserConfig.getUserConfigDir(), UserConfig.DAEMON_FILE);
if (daemonConfigFile.exists()) {
DaemonConfigTO daemonConfigTO = DaemonConfigTO.load(daemonConfigFile);
String localDirPath = FileUtil.getCanonicalFile(localDir).getAbsolutePath();
// Check if folder already exists
boolean folderExists = false;
for (FolderTO folderTO : daemonConfigTO.getFolders()) {
if (localDirPath.equals(folderTO.getPath())) {
folderExists = true;
break;
}
}
// Add to config if it's not already in there
if (!folderExists) {
logger.log(Level.INFO, "Adding folder to daemon config: " + localDirPath + ", and saving config at " + daemonConfigFile);
daemonConfigTO.getFolders().add(new FolderTO(localDirPath));
daemonConfigTO.save(daemonConfigFile);
return true;
}
else {
return false;