Function list

Source
pub fn list<P: AsRef<Path>>(path: P) -> Result<Vec<PathBuf>, FileError>
Expand description

Lists the contents of a directory.

§Arguments

  • path - The path of the directory to list.

§Returns

Returns a Result containing a Vec<PathBuf> of the directory contents, or a FileError.

§Examples

use dev_utils::file::{create, list};
use std::path::Path;

create("dir/file1.txt", "").unwrap();
create("dir/file2.txt", "").unwrap();
let contents = list("dir").unwrap();
assert_eq!(contents.len(), 2);