FileVisitorBuilder

sealed interface FileVisitorBuilder(source)

The builder to provide implementation of the FileVisitor that fileVisitor function builds.

Example:

val cleanVisitor = fileVisitor {
    onPreVisitDirectory { directory, _ ->
        if (directory.name == "build") {
            directory.deleteRecursively()
            FileVisitResult.SKIP_SUBTREE
        } else {
            FileVisitResult.CONTINUE
        }
    }

    onVisitFile { file, _ ->
        if (file.extension == "class") {
            file.deleteExisting()
        }
        FileVisitResult.CONTINUE
    }

    onVisitFileFailed { entry, _ ->
        Logger.warn("Could not traverse and clean $entry")
        FileVisitResult.CONTINUE
    }
}

Since Kotlin

2.1

Functions

Link copied to clipboard
abstract fun onPostVisitDirectory(function: (directory: Path, exception: IOException?) -> FileVisitResult)

Overrides the corresponding function of the built FileVisitor with the provided function.

Since Kotlin 2.1
Link copied to clipboard
abstract fun onPreVisitDirectory(function: (directory: Path, attributes: BasicFileAttributes) -> FileVisitResult)

Overrides the corresponding function of the built FileVisitor with the provided function.

Since Kotlin 2.1
Link copied to clipboard
abstract fun onVisitFile(function: (file: Path, attributes: BasicFileAttributes) -> FileVisitResult)

Overrides the corresponding function of the built FileVisitor with the provided function.

Since Kotlin 2.1
Link copied to clipboard
abstract fun onVisitFileFailed(function: (file: Path, exception: IOException) -> FileVisitResult)

Overrides the corresponding function of the built FileVisitor with the provided function.

Since Kotlin 2.1