aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2018-01-07 04:44:18 -0500
committerGitHub <noreply@github.com>2018-01-07 04:44:18 -0500
commitafe7437e0a0f6c315d383e0b6133b13a461c92af (patch)
tree3312b4841af831fe89a4a283fda306c490178961 /app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
parent8aece5e3f9209d7c161410c304655f0aec2d6054 (diff)
downloadfrost-afe7437e0a0f6c315d383e0b6133b13a461c92af.tar.gz
frost-afe7437e0a0f6c315d383e0b6133b13a461c92af.tar.bz2
frost-afe7437e0a0f6c315d383e0b6133b13a461c92af.zip
Enhancement/debug (#605)
* Finalize debugger * Add video logging
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt17
1 files changed, 17 insertions, 0 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
index bd9c1f99..1fb41dca 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
@@ -322,4 +322,21 @@ fun Element.first(vararg select: String): Element? {
if (e.size > 0) return e.first()
}
return null
+}
+
+fun File.createFreshFile(): Boolean {
+ if (exists()) {
+ if (!delete()) return false
+ } else {
+ val parent = parentFile
+ if (!parent.exists() && !parent.mkdirs())
+ return false
+ }
+ return createNewFile()
+}
+
+fun File.createFreshDir(): Boolean {
+ if (exists() && !deleteRecursively())
+ return false
+ return mkdirs()
} \ No newline at end of file