1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 00:17:11 -07:00

Better file detection.

This commit is contained in:
Cedric Beust 2017-03-09 13:48:39 -08:00
parent c590ed2ebd
commit e8bdd888a7

View file

@ -265,11 +265,19 @@ class KFiles {
}
fun saveFile(file: File, text: String) {
if (file.absoluteFile.parentFile.mkdirs()) {
var canCreate = true
with(file.absoluteFile.parentFile) {
if (!exists()) {
val success = mkdirs()
if (!success) {
warn("Couldn't create directory to save $file")
canCreate = false
}
}
}
if (canCreate) {
file.writeText(text)
kobaltLog(2, "Created $file")
} else {
warn("Couldn't create directory to save $file")
}
}