* @param file the File to check
* @throws PackagerException If the check fails
*/
private void checkOutputFile(File file) throws PackagerException {
if (file.isDirectory()) {
throw new PackagerException("%s is a directory!", file);
}
if (file.exists()) { // will be a file in this case.
if (!file.canWrite()) {
throw new PackagerException("Cannot write %s", file);
}
} else {
try {
if (!file.createNewFile()) {
throw new PackagerException("Failed to create %s", file);
}
} catch (IOException e) {
throw new PackagerException(
"Failed to create '%1$ss': %2$s", file, e.getMessage());
}
}
}