Function ergo_fs::glob
[−]
[src]
pub fn glob(pattern: &str) -> Result<GlobPathTypes, GlobPatternError>
Return an iterator that produces all the PathType
s that match the given pattern, which may be
absolute or relative to the current working directory.
This may return an error if the pattern is invalid.
This method uses the default match options and is equivalent to calling
glob_with(pattern, GlobOptions::new())
. Use glob_with
directly if you
want to use non-default match options.
When iterating, each result is a io::Result
which expresses the possibility that there was an
io::Error
when attempting to read the contents of the matched path.
Example
use ergo_fs::*; let mut count = 0; for entry in glob("src/glob_*.rs").unwrap() { match entry? { PathType::File(file) => println!("file: {}", file.display()), PathType::Dir(dir) => println!("dir: {}", dir.display()), } }
The above code will print:
⚠Be careful when using this code, it's not being tested!
/path/to/crate/src/glob_wrapper.rs
If there were more files with the prefix glob_
it would print more.