1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 08:27: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,12 +251,18 @@ public class Main {
// Save wrapperVersion.txt // Save wrapperVersion.txt
// //
log(2, " Writing " + VERSION_TXT); log(2, " Writing " + VERSION_TXT);
VERSION_TXT.getParentFile().mkdirs(); File parentDir = VERSION_TXT.getParentFile();
boolean success = parentDir.mkdirs();
if (success) {
try (FileWriter fw = new FileWriter(VERSION_TXT)) { try (FileWriter fw = new FileWriter(VERSION_TXT)) {
try (BufferedWriter bw = new BufferedWriter(fw)) { try (BufferedWriter bw = new BufferedWriter(fw)) {
bw.write(wrapperVersion); bw.write(wrapperVersion);
} }
} }
} else {
log(1, "Warning: could not create the directory " + parentDir.getAbsolutePath()
+ ", can't write " + VERSION_TXT);
}
} }
private void generateKobaltW(Path filePath) throws IOException { private void generateKobaltW(Path filePath) throws IOException {