1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-25 16:07:12 -07:00

Handle mkdirs() failing better.

Kind of fixes https://github.com/cbeust/kobalt/issues/181 but not really.
This commit is contained in:
Cedric Beust 2016-05-01 13:39:41 -07:00
parent 5799af8e37
commit 1a0af4582d

View file

@ -251,11 +251,17 @@ public class Main {
// Save wrapperVersion.txt
//
log(2, " Writing " + VERSION_TXT);
VERSION_TXT.getParentFile().mkdirs();
try (FileWriter fw = new FileWriter(VERSION_TXT)) {
try (BufferedWriter bw = new BufferedWriter(fw)) {
bw.write(wrapperVersion);
File parentDir = VERSION_TXT.getParentFile();
boolean success = parentDir.mkdirs();
if (success) {
try (FileWriter fw = new FileWriter(VERSION_TXT)) {
try (BufferedWriter bw = new BufferedWriter(fw)) {
bw.write(wrapperVersion);
}
}
} else {
log(1, "Warning: could not create the directory " + parentDir.getAbsolutePath()
+ ", can't write " + VERSION_TXT);
}
}