pub fn relative_files(
path: impl AsRef<Path>,
filter: &[&str],
) -> Result<Vec<PathBuf>, Error>
Expand description
Collects all files contained in a directory path
as a list of sorted relative paths.
Recursively iterates over all entries of path
(see read_dir
).
All returned entries are stripped using path
(see Path::strip_prefix
), effectively
providing a list of relative paths below path
.
The list of paths is sorted (see slice::sort
).
When providing file names using filter
, any path found ending with one of the filter names
will be skipped and not returned in the list of paths.
§Note
This function does not follow symlinks but instead returns the path of a symlink.
§Errors
Returns an error if
- calling
read_dir
onpath
or any of its subdirectories fails, - an entry in one of the (sub)directories can not be retrieved,
- or stripping the prefix of a file in a (sub)directory fails.