Skip to content

Commit

Permalink
ls: rename get_metadata_with_deref_opt
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvestre committed Dec 17, 2023
1 parent 134c619 commit 80f2409
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/uu/ls/src/ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1863,7 +1863,7 @@ impl PathData {
}

// if not, check if we can use Path metadata
match get_metadata(self.p_buf.as_path(), self.must_dereference) {
match get_metadata_with_deref_opt(self.p_buf.as_path(), self.must_dereference) {
Err(err) => {
// FIXME: A bit tricky to propagate the result here
out.flush().unwrap();
Expand Down Expand Up @@ -2055,7 +2055,7 @@ fn sort_entries(entries: &mut [PathData], config: &Config, out: &mut BufWriter<S
!match md {
None | Some(None) => {
// If it metadata cannot be determined, treat as a file.
get_metadata(p.p_buf.as_path(), true)
get_metadata_with_deref_opt(p.p_buf.as_path(), true)
.map_or_else(|_| false, |m| m.is_dir())
}
Some(Some(m)) => m.is_dir(),
Expand Down Expand Up @@ -2231,7 +2231,7 @@ fn enter_directory(
Ok(())
}

fn get_metadata(p_buf: &Path, dereference: bool) -> std::io::Result<Metadata> {
fn get_metadata_with_deref_opt(p_buf: &Path, dereference: bool) -> std::io::Result<Metadata> {
if dereference {
p_buf.metadata()
} else {
Expand Down Expand Up @@ -3100,7 +3100,7 @@ fn display_file_name(
// Otherwise, we use path.md(), which will guarantee we color to the same
// color of non-existent symlinks according to style_for_path_with_metadata.
if path.get_metadata(out).is_none()
&& get_metadata(
&& get_metadata_with_deref_opt(
target_data.p_buf.as_path(),
target_data.must_dereference,
)
Expand Down Expand Up @@ -3214,7 +3214,7 @@ fn color_name(
// should not exit with an err, if we are unable to obtain the target_metadata

let target = target_symlink.unwrap_or(path);
let md = match get_metadata(target.p_buf.as_path(), path.must_dereference) {
let md = match get_metadata_with_deref_opt(target.p_buf.as_path(), path.must_dereference) {
Ok(md) => md,
Err(_) => target.get_metadata(out).unwrap().clone(),
};
Expand Down Expand Up @@ -3265,7 +3265,7 @@ fn get_security_context(config: &Config, p_buf: &Path, must_dereference: bool) -
// does not support SELinux.
// Conforms to the GNU coreutils where a dangling symlink results in exit code 1.
if must_dereference {
match get_metadata(p_buf, must_dereference) {
match get_metadata_with_deref_opt(p_buf, must_dereference) {
Err(err) => {
// The Path couldn't be dereferenced, so return early and set exit code 1
// to indicate a minor error
Expand Down

0 comments on commit 80f2409

Please sign in to comment.