Просмотр исходного кода

Merge pull request #171 from kballard/symlink_to_root

Handle linking to root directories better
Benjamin Sago 8 лет назад
Родитель
Сommit
c49820a935
1 измененных файлов с 1 добавлено и 8 удалено
  1. 1 8
      src/output/mod.rs

+ 1 - 8
src/output/mod.rs

@@ -47,11 +47,7 @@ pub fn filename(file: &File, colours: &Colours, links: bool, classify: bool) ->
                 bits.push(colours.punctuation.paint("->"));
                 bits.push(Style::default().paint(" "));
 
-                if target.path.as_os_str() == "/" {
-                    // Do nothing when linking to the root directory.
-                    // The entirety of the path is the file name!
-                }
-                else if let Some(parent) = target.path.parent() {
+                if let Some(parent) = target.path.parent() {
                     let coconut = parent.components().count();
 
                     if coconut == 1 && parent.has_root() {
@@ -62,9 +58,6 @@ pub fn filename(file: &File, colours: &Colours, links: bool, classify: bool) ->
                         bits.push(colours.symlink_path.paint("/"));
                     }
                 }
-                else {
-                    bits.push(colours.symlink_path.paint("/"));
-                }
 
                 if !target.name.is_empty() {
                     bits.push(file_colour(colours, &target).paint(target.name));