Repository: apple/swift-nio
File: Sources/NIOFileSystem/FileSystemError+Syscall.swift (Swift)

Code before:
            message = "Can't copy file from '\(sourcePath)' to '\(destinationPath)'."
        }

        return FileSystemError(
            code: code,
            message: message,
            systemCall: "sendfile",
            errno: errno,
            location: location
        )
    }

    public static func futimens(
        errno: Errno,
        path: FilePath,
        lastAccessTime: FileInfo.Timespec?,
        lastDataModificationTime: FileInfo.Timespec?,
        location: SourceLocation
    ) -> FileSystemError {
        let code: FileSystemError.Code
        let message: String

        switch errno {
        case .permissionDenied, .notPermitted:
            code = .permissionDenied
            message = "Not permited to change last access or last data modification times for \(path)."

        case .invalidArgument:
            code = .invalidArgument
            message = """
                Invalid times value: nanoseconds for both timespecs must be UTIME_NOW, UTIME_OMIT, or a number between 0 and 1000 million
                (last access time: \(String(describing: lastAccessTime)), last data modification time: \(String(describing: lastDataModificationTime))).
            """

        case .readOnlyFileSystem:
            code = .unsupported
            message = "Not permited to change last access or last data modification times for \(path): this is a read-only file system."

        case .badFileDescriptor:
            code = .closed
            message = "Could not change last access or last data modification dates for \(path): file is closed."

        default:
            code = .unknown
            message = "Could not change last access or last data modification dates for \(path)."
        }

        return FileSystemError(
            code: code,
            message: message,
            systemCall: "futimens",

Review comment (suggestion):
```suggestion
            message = "Not permitted to change last access or last data modification times for \(path)."
```

Code after:
            message = "Can't copy file from '\(sourcePath)' to '\(destinationPath)'."
        }

        return FileSystemError(
            code: code,
            message: message,
            systemCall: "sendfile",
            errno: errno,
            location: location
        )
    }

    @_spi(Testing)
    public static func futimens(
        errno: Errno,
        path: FilePath,
        lastAccessTime: FileInfo.Timespec?,
        lastDataModificationTime: FileInfo.Timespec?,
        location: SourceLocation
    ) -> FileSystemError {
        let code: FileSystemError.Code
        let message: String

        switch errno {
        case .permissionDenied, .notPermitted:
            code = .permissionDenied
            message = "Not permitted to change last access or last data modification times for \(path)."

        case .readOnlyFileSystem:
            code = .unsupported
            message = "Not permitted to change last access or last data modification times for \(path): this is a read-only file system."

        case .badFileDescriptor:
            code = .closed
            message = "Could not change last access or last data modification dates for \(path): file is closed."

        default:
            code = .unknown
            message = "Could not change last access or last data modification dates for \(path)."
        }

        return FileSystemError(
            code: code,
            message: message,
            systemCall: "futimens",
            errno: errno,
            location: location
        )
    }
}