MPPFile#withoutSlashAtTheEnd

This commit is contained in:
InsanusMokrassar 2021-09-08 12:06:23 +06:00
parent d50dffec8c
commit 925702d315
2 changed files with 5 additions and 1 deletions

View File

@ -4,6 +4,8 @@
* `Versions`: * `Versions`:
* `UUID`: `0.3.0` -> `0.3.1` * `UUID`: `0.3.0` -> `0.3.1`
* `Common`:
* New property `MPPFile#withoutSlashAtTheEnd`
## 0.5.24 ## 0.5.24

View File

@ -7,7 +7,7 @@ import kotlin.jvm.JvmInline
@JvmInline @JvmInline
value class FileName(val string: String) { value class FileName(val string: String) {
val name: String val name: String
get() = string.takeLastWhile { it != '/' } get() = withoutSlashAtTheEnd.takeLastWhile { it != '/' }
val extension: String val extension: String
get() = name.takeLastWhile { it != '.' } get() = name.takeLastWhile { it != '.' }
val nameWithoutExtension: String val nameWithoutExtension: String
@ -17,6 +17,8 @@ value class FileName(val string: String) {
filename.substring(0, it) filename.substring(0, it)
} ?: filename } ?: filename
} }
val withoutSlashAtTheEnd: String
get() = string.dropLastWhile { it == '/' }
override fun toString(): String = string override fun toString(): String = string
} }