if (rootDir.isDirectory()) {
try {
// We need to delete everything under the root directory:
FileUtils.cleanDirectory(rootDir);
} catch (IOException e) {
throw new InterchangeSavingException(
"Failed to delete the old contents under the "
+ "specified project directory "
+ rootDir.getAbsolutePath() + ".");
}
}
else {
if (!rootDir.delete()) {
throw new InterchangeSavingException(
"Failed to create the root directory for the "
+ "new project because the parent directory contains a "
+ "file having the same name that could not be deleted.");
}
}
}
if (!rootDir.isDirectory()) {
if (!rootDir.mkdirs()) {
throw new InterchangeSavingException("Failed to create the directory "
+ rootDir.getAbsolutePath() + ".");
}
}
}