size

fun size(file: File, maxDepth: Int = Int.MAX_VALUE): Long

Calculates the size of a file / directory. If the file / directory does not exist, 0 is returned. This can hang if there are too many nested directories, so it is recommended to use a WithTimeout wrapper around this method.

Return

The size of the file / directory.

Parameters

file

The file / directory to calculate the size of.

maxDepth

The maximum depth of nested directories to calculate the size of.