Skip to content
Myr

dir_entry: Implement file_name() for broken symlinks

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Tavian Barnes · committed by David Peter · parent f0c50be · Browse files · 1 file+9 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+9 added−1 removed

  • other:+9 added−1 removed

1 file+9 added−1 removed

modified:src/dir_entry.rs+9 added-1 removed
119 unmodified lines
120121 fn file_name(&self) -> OsString {122 let name = match &self.inner {123 DirEntryInner::Normal(e) => e.file_name(),124 DirEntryInner::BrokenSymlink(_) => todo!(),124 DirEntryInner::BrokenSymlink(path) => {125 // Path::file_name() only works if the last component is Normal,126 // but we want it for all component types, so we open code it.127 // Copied from LsColors::style_for_path_with_metadata().128 path.components()129 .last()130 .map(|c| c.as_os_str())131 .unwrap_or_else(|| path.as_os_str())132 }133 };134 name.to_owned()135 }136
8 unmodified lines