mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 12:07:46 +00:00
ls/color_name: use the DirEntry if available
This commit is contained in:
parent
1bd8ce5ddf
commit
95fa81250e
1 changed files with 11 additions and 0 deletions
|
@ -3271,6 +3271,17 @@ fn color_name(
|
||||||
ls_colors: &LsColors,
|
ls_colors: &LsColors,
|
||||||
style_manager: &mut StyleManager,
|
style_manager: &mut StyleManager,
|
||||||
) -> String {
|
) -> String {
|
||||||
|
if !path.must_dereference {
|
||||||
|
// If we need to dereference (follow) a symlink, we will need to get the metadata
|
||||||
|
if let Some(de) = &path.de {
|
||||||
|
// There is a DirEntry, we don't need to get the metadata for the color
|
||||||
|
return match ls_colors.style_for(de) {
|
||||||
|
Some(style) => style_manager.apply_style(style, &name),
|
||||||
|
None => name,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
match ls_colors.style_for_path_with_metadata(&path.p_buf, md) {
|
match ls_colors.style_for_path_with_metadata(&path.p_buf, md) {
|
||||||
Some(style) => style_manager.apply_style(style, &name),
|
Some(style) => style_manager.apply_style(style, &name),
|
||||||
None => name,
|
None => name,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue