Added parent property
This commit is contained in:
parent
82628d8a6b
commit
563efc0ad8
|
@ -13,6 +13,8 @@ expect class File(path: String) {
|
||||||
|
|
||||||
val fileExtension: String
|
val fileExtension: String
|
||||||
|
|
||||||
|
val parent: File?
|
||||||
|
|
||||||
|
|
||||||
fun mkdirs(): Boolean
|
fun mkdirs(): Boolean
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package net.dankito.utils.multiplatform
|
package net.dankito.utils.multiplatform
|
||||||
|
|
||||||
import platform.Foundation.NSFileManager
|
import platform.Foundation.*
|
||||||
import platform.Foundation.NSURL
|
|
||||||
import platform.Foundation.lastPathComponent
|
|
||||||
|
|
||||||
|
|
||||||
actual class File actual constructor(path: String) : NSURL(fileURLWithPath = path) {
|
actual class File actual constructor(path: String) : NSURL(fileURLWithPath = path) {
|
||||||
|
@ -19,7 +17,10 @@ actual class File actual constructor(path: String) : NSURL(fileURLWithPath = pat
|
||||||
get() = lastPathComponent ?: ""
|
get() = lastPathComponent ?: ""
|
||||||
|
|
||||||
actual val fileExtension: String
|
actual val fileExtension: String
|
||||||
get() = filename.substringAfterLast('.', "")
|
get() = this.pathExtension ?: filename.substringAfterLast('.', "")
|
||||||
|
|
||||||
|
actual val parent: File?
|
||||||
|
get() = this.URLByDeletingLastPathComponent?.absoluteString?.let { File(it) }
|
||||||
|
|
||||||
|
|
||||||
actual fun mkdirs(): Boolean {
|
actual fun mkdirs(): Boolean {
|
||||||
|
|
|
@ -1,17 +1,15 @@
|
||||||
package net.dankito.utils.multiplatform
|
package net.dankito.utils.multiplatform
|
||||||
|
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
|
fun java.io.File.toFile(): File {
|
||||||
fun File.toFile(): net.dankito.utils.multiplatform.File {
|
return File(this.absolutePath)
|
||||||
return net.dankito.utils.multiplatform.File(this.absolutePath)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
actual class File actual constructor(path: String) : File(path) {
|
actual class File actual constructor(path: String) : java.io.File(path) {
|
||||||
|
|
||||||
actual constructor(folder: net.dankito.utils.multiplatform.File, filename: String)
|
actual constructor(folder: File, filename: String)
|
||||||
: this(File(folder, filename).absolutePath)
|
: this(java.io.File(folder, filename).absolutePath)
|
||||||
|
|
||||||
|
|
||||||
internal constructor() : this("") // for object deserializers
|
internal constructor() : this("") // for object deserializers
|
||||||
|
@ -27,6 +25,9 @@ actual class File actual constructor(path: String) : File(path) {
|
||||||
actual val fileExtension: String
|
actual val fileExtension: String
|
||||||
get() = this.extension
|
get() = this.extension
|
||||||
|
|
||||||
|
actual val parent: File?
|
||||||
|
get() = this.parentFile?.absolutePath?.let { File(it) }
|
||||||
|
|
||||||
|
|
||||||
actual override fun mkdirs(): Boolean {
|
actual override fun mkdirs(): Boolean {
|
||||||
return super.mkdirs()
|
return super.mkdirs()
|
||||||
|
|
Loading…
Reference in New Issue