kmp-file 0.6.1 indexed Simple file API offers consistent functionality across platforms, including file operations like reading, writing, directory management, and permissions. Ensures equivalent operations and extensions for cross-platform consistency.
Bring this to kpkg
This library is indexed from the KMP ecosystem and already resolves through kpkg.dev's Maven Central proxy. Maintainers can verify the namespace and publish future versions to kpkg for free hosting, real download stats, and signed-provenance pages.
Publishing coming soonMetadata
Owner 05nelsonm
Stars 19
Used by 4 libs
Health —
License Apache License 2.0
Latest 0.6.1
Repository github.com/05nelsonm/kmp-file
Updated 2026-02-14 fun main () {
val file = SysTempDir.resolve("path/to/../somewhere" )
.canonicalFile2()
.mkdirs2(mode = "700" , mustCreate = true )
.resolve("my_file.txt" )
assertFalse(file.exists2())
assertEquals(true , file.parentFile?.exists2())
val data = "Hello World!" .encodeToByteArray()
file.openReadWrite(excl = OpenExcl.MustCreate.of("644" )).use { stream ->
assertEquals(0L , stream.size())
assertEquals(0L , stream.postion())
stream.write(data )
assertEquals(data .size.toLong(), stream.size())
assertEquals(data .size.toLong(), stream.position())
val buf = ByteArray(data .size)
stream.position(new = 2L )
stream.read(buf, position = 0L )
assertEquals(2L , stream.position())
assertContentEquals(data , buf)
stream.size(new = 0L ).sync(meta = true ).write(buf)
}
file.appendBytes(excl = OpenExcl.MustExist, data )
file.chmod2("400" )
assertContentEquals(data + data , file.readBytes())
assertEquals("Hello World!Hello World!" , file.readUtf8())
file.delete2(ignoreReadOnly = true )
}
suspend fun main () {
AsyncFs.Default.with {
val file = SysTempDir.resolve("path/to/../somewhere" )
.canonicalFile2Async()
.mkdirs2Async(mode = "700" , mustCreate = true )
.resolve("my_file.txt" )
assertFalse(file.exists2Async())
assertEquals(true , file.parentFile?.exists2Async())
val data = "Hello World!" .encodeToByteArray()
file.openReadWriteAsync(excl = OpenExcl.MustCreate.of("644" )).useAsync { stream ->
assertEquals(0L , stream.sizeAsync())
assertEquals(0L , stream.postionAsync())
stream.write(data )
assertEquals(data .size.toLong(), stream.sizeAsync())
assertEquals(data .size.toLong(), stream.positionAsync())
val buf = ByteArray(data .size)
stream.positionAsync(new = 2L )
stream.readAsync(buf, position = 0L )
assertEquals(2L , stream.positionAsync())
assertContentEquals(data , buf)
stream.sizeAsync(new = 0L ).syncAsync(meta = true ).writeAsync(buf)
}
file.appendBytesAsync(excl = OpenExcl.MustExist, data )
file.chmod2Async("400" )
assertContentEquals(data + data , file.readBytesAsync())
assertEquals("Hello World!Hello World!" , file.readUtf8Async())
file.delete2Async(ignoreReadOnly = true )
}
}
Related libraries Surfaced from shared tags and platforms — no rankings paid for.
kmp-tor-common ★ 0
05nelsonm Facilitates common components for interaction with `kmp-tor` and `kmp-tor-resource`, offering public APIs, library path retrieval for Android, and resource packaging for installation. Shared: file okio ★ 9.0k
square Simplifies accessing, storing, and processing data by enhancing `java.io` and `java.nio` capabilities. Originated from OkHttp, ensuring robust performance for various data handling needs. Shared: file kotlinx-io ★ 1.5k
Kotlin Offers basic IO primitives with a mutable `Buffer` for efficient data handling, `Source` and `Sink` interfaces for data streams, and experimental filesystem support via `FileSystem` and `Path` classes. Shared: file FileKit ★ 1.5k
vinceglb Library simplifies picking and saving files, directories, and media across different platforms using native APIs. Features include file type selection, multiple picker modes, and easy integration with UI frameworks. Shared: file kfswatch ★ 135
irgaly Monitors file system changes across multiple directories, emitting events such as create, delete, and modify. Allows observing file events using flows, supports multiple platforms, and provides raw event access for debugging. Shared: file accompanist-lyrics-core ★ 39
6xingyv Offers smart auto-detection and parsing for various lyrics formats, karaoke-ready syllable timing, translation support, and extensibility for custom formats. Includes metadata extraction. Shared: file