mirror of
https://github.com/aphrody-labs/uutils-coreutils.git
synced 2026-10-13 21:07:43 +00:00
touch: simplify Unix access error check
This commit is contained in:
1 parent
cb4392c25e
commit
ca3e965d68
1 file changed
+5
-8
@@ -457,16 +457,13 @@ fn create_without_truncate(path: &Path) -> std::io::Result<fs::File> {
|
||||
|
||||
// GNU reports ordinary access failures as "cannot touch", while -c and -h
|
||||
// report failures to update timestamps as "setting times of".
|
||||
#[cfg(unix)]
|
||||
fn cannot_touch_on_access_error(opts: &Options, error: &Error) -> bool {
|
||||
if opts.no_create || opts.no_deref || error.kind() != ErrorKind::PermissionDenied {
|
||||
return false;
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
if error.raw_os_error() == Some(libc::EACCES) {
|
||||
return true;
|
||||
}
|
||||
!opts.no_create && !opts.no_deref && error.raw_os_error() == Some(libc::EACCES)
|
||||
}
|
||||
|
||||
#[cfg(not(unix))]
|
||||
fn cannot_touch_on_access_error(_opts: &Options, _error: &Error) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user