Function fs_extra::dir::ls

source ·
pub fn ls<P>(path: P, config: &HashSet<DirEntryAttr>) -> Result<LsResult>where
    P: AsRef<Path>,
Expand description

Returns a collection of directory entries with attributes specifying the information that should be returned.

This function takes to arguments:

  • path - Path to directory.

  • config - Set attributes which you want see in return data.

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::{ls, DirEntryAttr, LsResult};
use std::collections::HashSet;

let mut config = HashSet::new();
config.insert(DirEntryAttr::Name);
config.insert(DirEntryAttr::Size);
config.insert(DirEntryAttr::BaseInfo);

let result = ls("test", &config);
assert_eq!(2, ls_result.items.len());
assert_eq!(2, ls_result.base.len());