mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
ls: rename get_metadata_with_deref_opt
This commit is contained in:
parent
147721c24b
commit
445d0af277
1 changed files with 6 additions and 6 deletions
|
@ -1920,7 +1920,7 @@ impl PathData {
|
||||||
}
|
}
|
||||||
|
|
||||||
// if not, check if we can use Path metadata
|
// 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) => {
|
Err(err) => {
|
||||||
// FIXME: A bit tricky to propagate the result here
|
// FIXME: A bit tricky to propagate the result here
|
||||||
out.flush().unwrap();
|
out.flush().unwrap();
|
||||||
|
@ -2118,7 +2118,7 @@ fn sort_entries(entries: &mut [PathData], config: &Config, out: &mut BufWriter<S
|
||||||
!match md {
|
!match md {
|
||||||
None | Some(None) => {
|
None | Some(None) => {
|
||||||
// If it metadata cannot be determined, treat as a file.
|
// 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())
|
.map_or_else(|_| false, |m| m.is_dir())
|
||||||
}
|
}
|
||||||
Some(Some(m)) => m.is_dir(),
|
Some(Some(m)) => m.is_dir(),
|
||||||
|
@ -2294,7 +2294,7 @@ fn enter_directory(
|
||||||
Ok(())
|
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 {
|
if dereference {
|
||||||
p_buf.metadata()
|
p_buf.metadata()
|
||||||
} else {
|
} else {
|
||||||
|
@ -3136,7 +3136,7 @@ fn display_item_name(
|
||||||
// Otherwise, we use path.md(), which will guarantee we color to the same
|
// 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.
|
// color of non-existent symlinks according to style_for_path_with_metadata.
|
||||||
if path.get_metadata(out).is_none()
|
if path.get_metadata(out).is_none()
|
||||||
&& get_metadata(
|
&& get_metadata_with_deref_opt(
|
||||||
target_data.p_buf.as_path(),
|
target_data.p_buf.as_path(),
|
||||||
target_data.must_dereference,
|
target_data.must_dereference,
|
||||||
)
|
)
|
||||||
|
@ -3278,7 +3278,7 @@ fn color_name(
|
||||||
// should not exit with an err, if we are unable to obtain the target_metadata
|
// should not exit with an err, if we are unable to obtain the target_metadata
|
||||||
|
|
||||||
let target = target_symlink.unwrap_or(path);
|
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,
|
Ok(md) => md,
|
||||||
Err(_) => target.get_metadata(out).unwrap().clone(),
|
Err(_) => target.get_metadata(out).unwrap().clone(),
|
||||||
};
|
};
|
||||||
|
@ -3329,7 +3329,7 @@ fn get_security_context(config: &Config, p_buf: &Path, must_dereference: bool) -
|
||||||
// does not support SELinux.
|
// does not support SELinux.
|
||||||
// Conforms to the GNU coreutils where a dangling symlink results in exit code 1.
|
// Conforms to the GNU coreutils where a dangling symlink results in exit code 1.
|
||||||
if must_dereference {
|
if must_dereference {
|
||||||
match get_metadata(p_buf, must_dereference) {
|
match get_metadata_with_deref_opt(p_buf, must_dereference) {
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
// The Path couldn't be dereferenced, so return early and set exit code 1
|
// The Path couldn't be dereferenced, so return early and set exit code 1
|
||||||
// to indicate a minor error
|
// to indicate a minor error
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue