@@ -15,6 +15,7 @@ pub use self::owner::Owner;
1515pub use self :: permissions:: Permissions ;
1616pub use self :: size:: Size ;
1717pub use self :: symlink:: SymLink ;
18+ pub use crate :: flags:: Display ;
1819pub use crate :: icon:: Icons ;
1920
2021use std:: fs:: read_link;
@@ -39,8 +40,7 @@ impl Meta {
3940 pub fn from_path_recursive (
4041 path : & PathBuf ,
4142 depth : usize ,
42- list_hidden_files : bool ,
43- list_almost_all : bool ,
43+ display : Display ,
4444 ) -> Result < Self , std:: io:: Error > {
4545 let mut meta = Self :: from_path ( path) ?;
4646
@@ -59,44 +59,49 @@ impl Meta {
5959 }
6060 let mut content = Vec :: new ( ) ;
6161
62- if list_hidden_files {
63- let mut current_meta;
64- let mut parent_meta;
62+ match display {
63+ Display :: DisplayAll => {
64+ let mut current_meta;
65+ let mut parent_meta;
6566
66- let parent_path = match path. parent ( ) {
67- None => PathBuf :: from ( "/" ) ,
68- Some ( path) => PathBuf :: from ( path) ,
69- } ;
67+ let parent_path = match path. parent ( ) {
68+ None => PathBuf :: from ( "/" ) ,
69+ Some ( path) => PathBuf :: from ( path) ,
70+ } ;
7071
71- current_meta = Self :: from_path ( & PathBuf :: from ( path) ) ?;
72- current_meta. name . name = "." . to_string ( ) ;
72+ current_meta = Self :: from_path ( & PathBuf :: from ( path) ) ?;
73+ current_meta. name . name = "." . to_string ( ) ;
7374
74- parent_meta = Self :: from_path ( & PathBuf :: from ( parent_path) ) ?;
75- parent_meta. name . name = ".." . to_string ( ) ;
75+ parent_meta = Self :: from_path ( & PathBuf :: from ( parent_path) ) ?;
76+ parent_meta. name . name = ".." . to_string ( ) ;
7677
77- content. push ( current_meta) ;
78- content. push ( parent_meta) ;
79- }
78+ content. push ( current_meta) ;
79+ content. push ( parent_meta) ;
80+ }
81+ _ => ( ) ,
82+ } ;
8083
8184 for entry in meta. path . read_dir ( ) ? {
8285 let path = entry?. path ( ) ;
8386
84- if !list_hidden_files
85- && !list_almost_all
86- && path
87- . file_name ( )
88- . ok_or_else ( || Error :: new ( ErrorKind :: InvalidInput , "invalid file name" ) ) ?
89- . to_string_lossy ( )
90- . starts_with ( '.' )
91- {
92- continue ;
93- }
87+ match display {
88+ Display :: DisplayOnlyVisible => {
89+ if path
90+ . file_name ( )
91+ . ok_or_else ( || Error :: new ( ErrorKind :: InvalidInput , "invalid file name" ) ) ?
92+ . to_string_lossy ( )
93+ . starts_with ( '.' )
94+ {
95+ continue ;
96+ }
97+ }
98+ _ => ( ) ,
99+ } ;
94100
95101 let entry_meta = match Self :: from_path_recursive (
96102 & path. to_path_buf ( ) ,
97103 depth - 1 ,
98- list_hidden_files,
99- list_almost_all,
104+ display,
100105 ) {
101106 Ok ( res) => res,
102107 Err ( err) => {
0 commit comments