cp: use the function from uucore

This commit is contained in:
Sylvestre Ledru
2024-12-26 17:08:16 +01:00
parent ff50a37635
commit 1180905b5e
2 changed files with 6 additions and 8 deletions
+1
View File
@@ -30,6 +30,7 @@ uucore = { workspace = true, features = [
"backup-control",
"entries",
"fs",
"fsxattr",
"perms",
"mode",
"update-control",
+5 -8
View File
@@ -17,6 +17,8 @@ use std::os::unix::ffi::OsStrExt;
#[cfg(unix)]
use std::os::unix::fs::{FileTypeExt, PermissionsExt};
use std::path::{Path, PathBuf, StripPrefixError};
#[cfg(all(unix, not(any(target_os = "android", target_os = "macos"))))]
use uucore::fsxattr::copy_xattrs;
use clap::{builder::ValueParser, crate_version, Arg, ArgAction, ArgMatches, Command};
use filetime::FileTime;
@@ -1603,16 +1605,11 @@ pub(crate) fn copy_attributes(
})?;
handle_preserve(&attributes.xattr, || -> CopyResult<()> {
#[cfg(all(unix, not(target_os = "android")))]
#[cfg(all(unix, not(any(target_os = "android", target_os = "macos"))))]
{
let xattrs = xattr::list(source)?;
for attr in xattrs {
if let Some(attr_value) = xattr::get(source, attr.clone())? {
xattr::set(dest, attr, &attr_value[..])?;
}
}
copy_xattrs(source, dest)?;
}
#[cfg(not(all(unix, not(target_os = "android"))))]
#[cfg(not(all(unix, not(any(target_os = "android", target_os = "macos")))))]
{
// The documentation for GNU cp states:
//