AtomicFileWriter

Writes files atomically: content is first written to a temporary sibling file which is then moved into place with StandardCopyOption.ATOMIC_MOVE, so readers never observe partially written output. Write failures propagate to the caller; the temporary file is always cleaned up.

Functions

Link copied to clipboard
fun write(outFile: File, writeContent: (File) -> Unit)

Writes to outFile by invoking writeContent against a temporary sibling file and atomically moving the result into place. Missing parent directories are created.