@Override
public File iniFile() {
final Optional<URL> url = new ResolveGeogigDir(platform).call();
if (!url.isPresent()) {
throw new ConfigException(StatusCode.INVALID_LOCATION);
}
/*
* See http://weblogs.java.net/blog/kohsuke/archive/2007/04/how_to_convert.html for
* explanation on this idiom.
*/
File localConfigFile;
try {
localConfigFile = new File(new File(url.get().toURI()), "config");
} catch (URISyntaxException e) {
localConfigFile = new File(url.get().getPath(), "config");
}
return localConfigFile;
}
};
this.global = new INIFile() {
@Override
public File iniFile() {
File home = platform.getUserHome();
if (home == null) {
throw new ConfigException(StatusCode.USERHOME_NOT_SET);
}
File globalConfig = new File(home.getPath(), ".geogigconfig");
try {
globalConfig.createNewFile();
} catch (IOException e) {
throw new ConfigException(e, StatusCode.CANNOT_WRITE);
}
return globalConfig;
}
};
}