import kotlin.io.path.ExperimentalPathApi
import kotlin.io.path.Path
import kotlin.io.path.copyToRecursively
import kotlin.io.path.deleteRecursively
// *** before: ***
// only java.io.File had a recursive walk:
// File("src").copyRecursively(File("dst"), overwrite = true)
// File("dst").deleteRecursively()
// *** in version 1.8: *** (experimental)
@OptIn(ExperimentalPathApi::class)
fun sync() {
val src = Path("src")
val dst = Path("dst")
src.copyToRecursively(dst, followLinks = false, overwrite = true)
// and the errors of a single entry can be handled instead of stopping
dst.deleteRecursively()
}