File tree Expand file tree Collapse file tree 2 files changed +20
-5
lines changed Expand file tree Collapse file tree 2 files changed +20
-5
lines changed Original file line number Diff line number Diff line change 1
- import kotlinx.cinterop.toKString
2
- import platform.posix.getpass
1
+ import kotlin.time.Instant
2
+ import kotlinx.cinterop.*
3
+ import kotlinx.io.files.Path
4
+ import platform.posix.*
3
5
4
6
actual fun readPassword (prompt : String ) = getpass(prompt)?.toKString()
7
+
8
+ fun getMTime (path : Path ): Instant {
9
+ memScoped {
10
+ val stat = alloc< stat> ()
11
+ if (lstat(path.toString(), stat.ptr) != 0 ) {
12
+ throw IllegalStateException (" Failed to get mtime for $path " )
13
+ }
14
+ return Instant .fromEpochSeconds(stat.st_mtim.tv_sec, stat.st_mtim.tv_nsec)
15
+ }
16
+ }
Original file line number Diff line number Diff line change 1
- import kotlin.test.assertEquals
2
- import kotlinx.io.Buffer
1
+ import kotlin.test.*
2
+ import kotlinx.io.*
3
3
import kotlinx.io.files.*
4
- import kotlinx.io.readFloat
5
4
6
5
fun buffer () {
7
6
val buffer = Buffer ()
@@ -14,3 +13,7 @@ fun dir() {
14
13
println (" SystemTemporaryDirectory: $SystemTemporaryDirectory " )
15
14
SystemFileSystem .list(Path (" ." )).forEach { println (it) }
16
15
}
16
+
17
+ fun Path.append (data : String ) {
18
+ SystemFileSystem .sink(this , append = true ).buffered().use { f -> f.writeString(data) }
19
+ }
You can’t perform that action at this time.
0 commit comments