File tree 1 file changed +12
-9
lines changed 1 file changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -326,17 +326,20 @@ pub fn remove(files: &[&OsStr], options: &Options) -> bool {
326
326
fn handle_dir ( path : & Path , options : & Options ) -> bool {
327
327
let mut had_err = false ;
328
328
329
- let path_as_str = path. as_os_str ( ) . to_str ( ) . unwrap ( ) ;
330
329
#[ cfg( unix) ]
331
- if path_as_str. ends_with ( "/." ) || path_as_str. ends_with ( "/.." ) {
332
- show_error ! (
333
- "refusing to remove '.' or '..' directory: skipping {}" ,
334
- path. quote( )
335
- ) ;
336
- return true ;
337
- }
330
+ let del = "/" ;
338
331
#[ cfg( windows) ]
339
- if path_as_str. ends_with ( "\\ ." ) || path_as_str. ends_with ( "\\ .." ) {
332
+ let del = "\\ " ;
333
+
334
+ if path
335
+ . to_str ( )
336
+ . unwrap ( )
337
+ . ends_with ( format ! ( "{}." , del) . as_str ( ) )
338
+ || path
339
+ . to_str ( )
340
+ . unwrap ( )
341
+ . ends_with ( format ! ( "{}.." , del) . as_str ( ) )
342
+ {
340
343
show_error ! (
341
344
"refusing to remove '.' or '..' directory: skipping {}" ,
342
345
path. quote( )
You can’t perform that action at this time.
0 commit comments