Module fts::walkdir
[−]
[src]
A library for directory walking.
Examples
The simplest usage is the following.
let path = Path::new( "test_data" ); for p in WalkDir::new( WalkDirConf::new( path ) ) { println!( "{:?}", p.unwrap() ); }
WalkDirConf
is a configuration builder of directory walking.
For example, if you want to follow symblic links, you can use follow_symlink()
like the following.
let path = Path::new( "test_data" ); for p in WalkDir::new( WalkDirConf::new( path ).follow_symlink() ) { println!( "{:?}", p.unwrap() ); }
If you don't want to use metadata of files, you can use no_metadata()
for performance optimization like the following.
let path = Path::new( "test_data" ); for p in WalkDir::new( WalkDirConf::new( path ).no_metadata() ) { println!( "{:?}", p.unwrap() ); }
If you want to enumerate directories sorted by the creation time of file, you can use sort_by_ctime()
.
sort_ascending()
means sorting in ascending order, and sort_descending()
means descending order.
let path = Path::new( "test_data" ); for p in WalkDir::new( WalkDirConf::new( path ).sort_by_ctime().sort_ascending() ) { println!( "{:?}", p.unwrap() ); }
Structs
DirEntry |
A directory entry like |
FileType |
A file type of the directory entry like |
Iter |
A iterator for enumerating directory entries. |
WalkDir |
A builder to create an iterator for directory walking. |
WalkDirConf |
A configuration builder of the settings for directory walking. |