From c78c89e27405aa99d362957d7c19ce0474d4ec0b Mon Sep 17 00:00:00 2001 From: Nikolay Edigaryev Date: Thu, 31 Oct 2024 21:33:03 +0100 Subject: [PATCH] utimes(2): use errno to explain the error (#931) --- Sources/tart/URL+AccessDate.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sources/tart/URL+AccessDate.swift b/Sources/tart/URL+AccessDate.swift index 3d43d20..3604073 100644 --- a/Sources/tart/URL+AccessDate.swift +++ b/Sources/tart/URL+AccessDate.swift @@ -1,4 +1,5 @@ import Foundation +import System extension URL { func accessDate() throws -> Date { @@ -13,7 +14,9 @@ extension URL { let times = [accessDate.asTimeval(), modificationDate.asTimeval()] let ret = utimes(path, times) if ret != 0 { - throw RuntimeError.FailedToUpdateAccessDate("utimes(2) failed: \(ret.explanation())") + let details = Errno(rawValue: CInt(errno)) + + throw RuntimeError.FailedToUpdateAccessDate("utimes(2) failed: \(details)") } } }