KFile
0.2.0indexedA Kotlin/Native + JVM Library for file operations
0
Stars
1
Used by
dependents
—
Health
/ 100
A Kotlin/Native + JVM Library for file operations
A Kotlin Multiplatform library providing a unified file-system API for macOS, Linux, Windows, and JVM.
import es.jvbabi.kfile.File
val cwd = File.getWorkingDirectory()
val home = File.getUserHomeDirectory()
val exe = File.getCurrentExecutableFile()
val file = cwd.resolve("build.gradle.kts")
if (file.exists()) {
val text = file.readText()
file.appendText("\n// appended")
}
// settings.gradle.kts
dependencyResolutionManagement {
repositories { mavenCentral() }
}
// build.gradle.kts
kotlin {
sourceSets {
commonMain.dependencies {
implementation("io.github.julius-babies:kfile:VERSION")
}
}
}
Replace VERSION with the latest version available on Maven Central.
| Method | Returns |
|---|
File(path) | Constructs a File, resolving relative paths against the working directory |
File.isPathAbsolute(path) | Boolean |
File.getWorkingDirectory() | File |
File.getUserHomeDirectory() | File |
File.getTempDirectory() | File |
File.getCurrentExecutableFile() | File |
| Property | Type |
|---|
absolutePath | String |
name | String |
extension | String |
nameWithoutExtension | String |
parent | File? |
size | Long |
| Method | Description |
|---|
exists() | Checks if the file or directory exists |
isDirectory | Checks if the path is a directory |
isFile | Checks if the path is a regular file |
isExecutable | Checks if the file is executable |
setExecutable(executable) | Sets or removes the executable permission |
resolve(path) | Resolves a child path relative to this file |
delete(recursive) | Deletes the file or directory |
mkdir(recursive) | Creates the directory |
readText() / writeText(text) / appendText(text) | Text I/O |
readBytes() / writeBytes(bytes) / appendBytes(bytes) | Binary I/O |
readLines() / forEachLine(action) | Line-by-line reading |
source() / sink() / appendSink() | Streaming via kotlinx.io |
listFiles() | Lists children of a directory |
copy(to) | Copies the file (overwrites destination) |
Surfaced from shared tags and platforms — no rankings paid for.