mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Better file detection.
This commit is contained in:
parent
c590ed2ebd
commit
e8bdd888a7
1 changed files with 11 additions and 3 deletions
|
@ -265,11 +265,19 @@ class KFiles {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun saveFile(file: File, text: String) {
|
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)
|
file.writeText(text)
|
||||||
kobaltLog(2, "Created $file")
|
kobaltLog(2, "Created $file")
|
||||||
} else {
|
|
||||||
warn("Couldn't create directory to save $file")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue