Function fs_extra::dir::get_size

source ·
pub fn get_size<P>(path: P) -> Result<u64>where
    P: AsRef<Path>,
Expand description

Returns the size of the file or directory in bytes.(!important: folders size not count)

If used on a directory, this function will recursively iterate over every file and every directory inside the directory. This can be very time consuming if used on large directories.

Does not follow symlinks.

Errors

This function will return an error in the following situations, but is not limited to just these cases:

  • This path directory does not exist.
  • Invalid path.
  • The current process does not have the permission to access path.

Examples

extern crate fs_extra;
use fs_extra::dir::get_size;

let folder_size = get_size("dir")?;
println!("{}", folder_size); // print directory size in bytes