boolean freshInstall = (!configDir.exists());
if (freshInstall)
{
if (!configDir.mkdir())
{
throw new XSException("Can't create directory to store mapping files : "
+ configDir.getAbsolutePath());
}
}
if ((freshInstall) || (settings.isSyncMappingsAtStartup()))
{
File destDir = new File(settings.getMappingsStorageDir(), "default");
if ((!destDir.isDirectory()) && (!destDir.mkdir()))
{
throw new XSException("Can't create directory to store DEFAULT mapping files : "
+ configDir.getAbsolutePath());
}
for (File file : DefaultMappingsRegistry.getDefaultMappings())
{
File destFile = new File(destDir, file.getName());
if ((!destFile.exists()) || (settings.isOverwriteWhenSyncMappings()))
{
try
{
FileUtil.copy(file, destFile);
}
catch (IOException e)
{
throw new XSException("Can't copy configuration file to "
+ destFile.getAbsolutePath(), e);
}
}
}
}