File

expect class File

Class giving access to several things like:

  • path

  • absolute path

  • parent-directory

  • whether an instance is a file or directory

  • separator / path separator depending on the filesystem

  • constructor accepting a parent and the actual file

  • constructor accepting the full path of the file

  • constructor accepting the relative path to the file in relation to the current working directory

  • name of the file

  • check read and write access

  • whether the file exists

  • deletion

  • recursive deletion if the file is a directory

  • list contents of the file if it is a directory

  • create a directory

  • rename

  • move

  • copy

  • copy recursively

  • filesize

  • directory size

See the File-class from Java for reference.

Author

Griefed

actual typealias File = java.io.File

Type alias to link File to java.io.File

Functions

Link copied to clipboard
expect fun File.createDirectories(create: Boolean = false, directory: Boolean = false)

All parent directories are created, but not the file itself.

Link copied to clipboard
expect fun File.deleteQuietly(): Boolean

Try and delete this file or directory quietly. Deleting something quietly means that

Link copied to clipboard
expect fun File.filteredWalk(filters: List<String>, filterType: FilterType = FilterType.CONTAINS, direction: <Error class: unknown class> = FileWalkDirection.TOP_DOWN, recursive: Boolean = true): MutableList<File>

Walk this directory and return all file-objects which match the specified filter-type using the passed list of filters.

Link copied to clipboard
expect fun File.regexWalk(filters: List<<Error class: unknown class>>, direction: <Error class: unknown class> = FileWalkDirection.TOP_DOWN): MutableList<File>

Walk this directory and return all file-objects which match any of the regular expressions in the provided list.

Link copied to clipboard
expect fun File.size(): Double

Acquire the size of this file or directory in bytes. If this file-object denotes a directory, then the size of all files in the directory will be checked and the sum of them returned.