api / org.gradle.api.file / FileTreeElement

FileTreeElement

interface FileTreeElement

Information about a file in a FileTree.

Functions

copyTo

abstract fun copyTo(output: OutputStream): Unit

Copies the content of this file to an output stream. Generally, calling this method is more performant than calling new FileInputStream(getFile()).

abstract fun copyTo(target: File): Boolean

Copies this file to the given target file. Does not copy the file if the target is already a copy of this file.

getFile

abstract fun getFile(): File

Returns the file being visited.

getLastModified

abstract fun getLastModified(): Long

Returns the last modified time of this file at the time of file traversal.

getMode

abstract fun getMode(): Int

Returns the Unix permissions of this file, e.g. 0644.

getName

abstract fun getName(): String

Returns the base name of this file.

getPath

abstract fun getPath(): String

Returns the path of this file, relative to the root of the containing file tree. Always uses '/' as the hierarchy separator, regardless of platform file separator. Same as calling getRelativePath().getPathString().

getRelativePath

abstract fun getRelativePath(): RelativePath

Returns the path of this file, relative to the root of the containing file tree.

getSize

abstract fun getSize(): Long

Returns the size of this file at the time of file traversal.

isDirectory

abstract fun isDirectory(): Boolean

Returns true if this element is a directory, or false if this element is a regular file.

open

abstract fun open(): InputStream

Opens this file as an input stream. Generally, calling this method is more performant than calling new FileInputStream(getFile()).

Inheritors

FileCopyDetails

interface FileCopyDetails : FileTreeElement, ContentFilterable

Provides details about a file or directory about to be copied, and allows some aspects of the destination file to be modified.

Using this interface, you can change the destination path of the file, filter the content of the file, or exclude the file from the result entirely.

Access to the source file itself after any filters have been added is not a supported operation.

FileVisitDetails

interface FileVisitDetails : FileTreeElement

Provides access to details about a file or directory being visited by a FileVisitor.