Repository: ogham/exa
File: src/fs/dir.rs (Rust)

Code before:
}

impl<'dir, 'ig> Files<'dir, 'ig> {
    fn parent(&self) -> PathBuf {
        // We can’t use `Path#parent` here because all it does is remove the
        // last path component, which is no good for us if the path is
        // relative. For example, while the parent of `/testcases/files` is
        // `/testcases`, the parent of `.` is an empty path. Adding `..` on
        // the end is the only way to get to the *actual* parent directory.
        self.dir.path.join("..")
    }

    /// Go through the directory until we encounter a file we can list (which
    /// varies depending on the dotfile visibility flag)
    fn next_visible_file(&mut self) -> Option<Result<File<'dir>, (PathBuf, io::Error)>> {
        loop {
            if let Some(path) = self.inner.next() {
                let filename = File::filename(path);
                if ! self.dotfiles && filename.starts_with('.') {
                    continue;
                }

                if self.git_ignoring {
                    let git_status = self.git.map(|g| g.get(path, false)).unwrap_or_default();
                    if git_status.unstaged == GitStatus::Ignored {
                         continue;
                    }
                }

                return Some(File::from_args(path.clone(), self.dir, filename)
                                 .map_err(|e| (path.clone(), e)))
            }

            return None
        }
    }
}

/// 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 DotsNext {

    /// List the `.` directory next.
    Dot,

    /// List the `..` directory next.
    DotDot,

    /// Forget about the dot directories and just list files.
    Files,
}

Review comment (suggestion):
I think this is overdoing it. Python uses `__init__.py` for top-level modules, and this hides all such files. If you're running this build with msys/cygwin, most likely your dotfiles actually start with '.' anyway.

Code after:
}

impl<'dir, 'ig> Files<'dir, 'ig> {
    fn parent(&self) -> PathBuf {
        // We can’t use `Path#parent` here because all it does is remove the
        // last path component, which is no good for us if the path is
        // relative. For example, while the parent of `/testcases/files` is
        // `/testcases`, the parent of `.` is an empty path. Adding `..` on
        // the end is the only way to get to the *actual* parent directory.
        self.dir.path.join("..")
    }

    /// Go through the directory until we encounter a file we can list (which
    /// varies depending on the dotfile visibility flag)
    fn next_visible_file(&mut self) -> Option<Result<File<'dir>, (PathBuf, io::Error)>> {
        loop {
            if let Some(path) = self.inner.next() {
                let filename = File::filename(path);
                if ! self.dotfiles && filename.starts_with('.') {
                    continue;
                }

                // Also hide _prefix files on Windows because it's used by old applications
                // as an alternative to dot-prefix files.
                #[cfg(windows)]
                if ! self.dotfiles && filename.starts_with('_') {
                    continue;
                }

                if self.git_ignoring {
                    let git_status = self.git.map(|g| g.get(path, false)).unwrap_or_default();
                    if git_status.unstaged == GitStatus::Ignored {
                         continue;
                    }
                }

                return Some(File::from_args(path.clone(), self.dir, filename)
                                 .map_err(|e| (path.clone(), e)))
            }

            return None
        }
    }
}

/// 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 DotsNext {

    /// List the `.` directory next.
    Dot,