File system manipulation in Kotlin with a pluggable file system abstraction. You can set the content of files and directories, and the file system to use.
To create a file system (automatically):
val directory = dir("path", Automatic) {
text("plainfile.txt") {
content = "hello"
}
binary("binary.png") {
content = "goodbye".byteInputStream()
}
dir("directory") {
text("file2.html") {
content = "<html/>"
}
}
}
// directory is created automatically
directory.delete()You can manipulate files in a nested way to only create/delete the parts you need:
dir("parent").dir("child").text("file.txt").delete()- Disk
- In-Memory