File tree 1 file changed +27
-0
lines changed
1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ use std::{fmt, thread};
7
7
8
8
use anyhow:: { anyhow, bail, Context , Result } ;
9
9
use tracing:: { debug, debug_span, warn, Span } ;
10
+ use walkdir:: DirEntry ;
10
11
11
12
use crate :: core:: Config ;
12
13
use crate :: ui:: { Spinner , Status } ;
@@ -163,3 +164,29 @@ pub fn make_executable(path: &Path) {
163
164
164
165
#[ cfg( windows) ]
165
166
pub fn make_executable ( _path : & Path ) { }
167
+
168
+ #[ cfg( unix) ]
169
+ pub fn is_hidden ( entry : & DirEntry ) -> bool {
170
+ is_hidden_by_dot ( entry)
171
+ }
172
+
173
+ #[ cfg( windows) ]
174
+ pub fn is_hidden ( entry : & DirEntry ) -> bool {
175
+ use std:: os:: windows:: prelude:: * ;
176
+
177
+ let is_hidden = std:: fs:: metadata ( entry. path ( ) )
178
+ . ok ( )
179
+ . map ( |metadata| metadata. file_attributes ( ) )
180
+ . map ( |attributes| ( attributes & 0x2 ) > 0 )
181
+ . unwrap_or ( false ) ;
182
+
183
+ is_hidden || is_hidden_by_dot ( entry)
184
+ }
185
+
186
+ fn is_hidden_by_dot ( entry : & DirEntry ) -> bool {
187
+ entry
188
+ . file_name ( )
189
+ . to_str ( )
190
+ . map ( |s| s. starts_with ( '.' ) )
191
+ . unwrap_or ( false )
192
+ }
You can’t perform that action at this time.
0 commit comments