Merge pull request #171 from kballard/symlink_to_root

Handle linking to root directories better
This commit is contained in:
Benjamin Sago 2017-04-30 09:00:59 +01:00 committed by GitHub
commit c49820a935

View File

@ -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));