|
|
@@ -82,7 +82,7 @@ pub struct Files<'dir, 'ig> {
|
|
|
|
|
|
/// Whether the `.` or `..` directories should be produced first, before
|
|
|
/// any files have been listed.
|
|
|
- dots: Dots,
|
|
|
+ dots: DotsNext,
|
|
|
|
|
|
ignore: Option<&'ig IgnoreCache>,
|
|
|
}
|
|
|
@@ -109,7 +109,7 @@ impl<'dir, 'ig> Files<'dir, 'ig> {
|
|
|
if i.is_ignored(path) { continue }
|
|
|
}
|
|
|
|
|
|
- return Some(File::new(path.clone(), self.dir, filename)
|
|
|
+ return Some(File::from_args(path.clone(), self.dir, filename)
|
|
|
.map_err(|e| (path.clone(), e)))
|
|
|
}
|
|
|
else {
|
|
|
@@ -121,16 +121,16 @@ impl<'dir, 'ig> Files<'dir, 'ig> {
|
|
|
|
|
|
/// The dot directories that need to be listed before actual files, if any.
|
|
|
/// If these aren’t being printed, then `FilesNext` is used to skip them.
|
|
|
-enum Dots {
|
|
|
+enum DotsNext {
|
|
|
|
|
|
/// List the `.` directory next.
|
|
|
- DotNext,
|
|
|
+ Dot,
|
|
|
|
|
|
/// List the `..` directory next.
|
|
|
- DotDotNext,
|
|
|
+ DotDot,
|
|
|
|
|
|
/// Forget about the dot directories and just list files.
|
|
|
- FilesNext,
|
|
|
+ Files,
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -138,18 +138,18 @@ impl<'dir, 'ig> Iterator for Files<'dir, 'ig> {
|
|
|
type Item = Result<File<'dir>, (PathBuf, io::Error)>;
|
|
|
|
|
|
fn next(&mut self) -> Option<Self::Item> {
|
|
|
- if let Dots::DotNext = self.dots {
|
|
|
- self.dots = Dots::DotDotNext;
|
|
|
- Some(File::new(self.dir.path.to_path_buf(), self.dir, String::from("."))
|
|
|
- .map_err(|e| (Path::new(".").to_path_buf(), e)))
|
|
|
- }
|
|
|
- else if let Dots::DotDotNext = self.dots {
|
|
|
- self.dots = Dots::FilesNext;
|
|
|
- Some(File::new(self.parent(), self.dir, String::from(".."))
|
|
|
- .map_err(|e| (self.parent(), e)))
|
|
|
- }
|
|
|
- else {
|
|
|
- self.next_visible_file()
|
|
|
+ match self.dots {
|
|
|
+ DotsNext::Dot => {
|
|
|
+ self.dots = DotsNext::DotDot;
|
|
|
+ Some(File::from_args(self.dir.path.to_path_buf(), self.dir, String::from("."))
|
|
|
+ .map_err(|e| (Path::new(".").to_path_buf(), e)))
|
|
|
+ },
|
|
|
+ DotsNext::DotDot => {
|
|
|
+ self.dots = DotsNext::Files;
|
|
|
+ Some(File::from_args(self.parent(), self.dir, String::from(".."))
|
|
|
+ .map_err(|e| (self.parent(), e)))
|
|
|
+ },
|
|
|
+ DotsNext::Files => self.next_visible_file(),
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -189,11 +189,11 @@ impl DotFilter {
|
|
|
}
|
|
|
|
|
|
/// Whether this filter should add dot directories to a listing.
|
|
|
- fn dots(self) -> Dots {
|
|
|
+ fn dots(self) -> DotsNext {
|
|
|
match self {
|
|
|
- DotFilter::JustFiles => Dots::FilesNext,
|
|
|
- DotFilter::Dotfiles => Dots::FilesNext,
|
|
|
- DotFilter::DotfilesAndDots => Dots::DotNext,
|
|
|
+ DotFilter::JustFiles => DotsNext::Files,
|
|
|
+ DotFilter::Dotfiles => DotsNext::Files,
|
|
|
+ DotFilter::DotfilesAndDots => DotsNext::Dot,
|
|
|
}
|
|
|
}
|
|
|
}
|