mirror of
https://github.com/Llewellynvdm/exa.git
synced 2024-11-10 23:00:56 +00:00
Print . and .. components properly
`Path.file_name()` returns `None` if the path ends in `.` or `..`, which causes e.g. `exa -d ..` to print a blank line.
This commit is contained in:
parent
3087565c01
commit
dd63774e37
@ -102,8 +102,8 @@ impl<'dir> File<'dir> {
|
|||||||
|
|
||||||
/// Create a new File object from the given metadata result, and other data.
|
/// Create a new File object from the given metadata result, and other data.
|
||||||
pub fn with_metadata(metadata: fs::Metadata, path: &Path, parent: Option<&'dir Dir>) -> File<'dir> {
|
pub fn with_metadata(metadata: fs::Metadata, path: &Path, parent: Option<&'dir Dir>) -> File<'dir> {
|
||||||
let filename = match path.file_name() {
|
let filename = match path.components().next_back() {
|
||||||
Some(name) => name.to_string_lossy().to_string(),
|
Some(comp) => comp.as_os_str().to_string_lossy().to_string(),
|
||||||
None => String::new(),
|
None => String::new(),
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -174,8 +174,8 @@ impl<'dir> File<'dir> {
|
|||||||
None => path
|
None => path
|
||||||
};
|
};
|
||||||
|
|
||||||
let filename = match target_path.file_name() {
|
let filename = match target_path.components().next_back() {
|
||||||
Some(name) => name.to_string_lossy().to_string(),
|
Some(comp) => comp.as_os_str().to_string_lossy().to_string(),
|
||||||
None => String::new(),
|
None => String::new(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user