1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use std::{fs::DirEntry, io, path::PathBuf};
pub mod index;
pub mod listing;
#[derive(Debug)]
pub struct Directory {
pub base: PathBuf,
pub path: PathBuf,
}
impl Directory {
pub fn new(base: PathBuf, path: PathBuf) -> Directory {
Directory { base, path }
}
pub fn is_visible(&self, entry: &io::Result<DirEntry>) -> bool {
if let Ok(ref entry) = *entry {
if let Some(name) = entry.file_name().to_str() {
if name.starts_with('.') {
return false;
}
}
if let Ok(ref md) = entry.metadata() {
let ft = md.file_type();
return ft.is_dir() || ft.is_file() || ft.is_symlink();
}
}
false
}
}