Implemented deleting files

This commit is contained in:
dankito 2020-09-14 00:58:29 +02:00
parent 8cac7b52ee
commit 40bbb2b8f5
3 changed files with 10 additions and 0 deletions

View File

@ -18,4 +18,6 @@ expect class File(path: String) {
fun mkdirs(): Boolean fun mkdirs(): Boolean
fun delete(): Boolean
} }

View File

@ -27,6 +27,10 @@ actual class File actual constructor(path: String) : NSURL(fileURLWithPath = pat
return NSFileManager.defaultManager.createDirectoryAtURL(this, true, null, null) return NSFileManager.defaultManager.createDirectoryAtURL(this, true, null, null)
} }
actual fun delete(): Boolean {
return NSFileManager.defaultManager.removeItemAtURL(this, null)
}
override fun description(): String? { override fun description(): String? {
return getAbsolutePath() return getAbsolutePath()

View File

@ -37,6 +37,10 @@ actual class File actual constructor(path: String) : java.io.File(path) {
return super.mkdirs() return super.mkdirs()
} }
actual override fun delete(): Boolean {
return super.delete()
}
override fun toString(): String { override fun toString(): String {
return absolutePath return absolutePath