Repository: apple/swift-nio
File: Sources/NIOFileSystem/FileSystem.swift (Swift)

Code before:
        to destinationPath: FilePath
    ) -> Result<Void, FileSystemError> {
        func makeOnUnavailableError(
            path: FilePath,
            location: FileSystemError.SourceLocation
        ) -> FileSystemError {
            FileSystemError(
                code: .closed,
                message: "Can't copy '\(sourcePath)' to '\(destinationPath)', '\(path)' is closed.",
                cause: nil,
                location: location
            )
        }

        #if canImport(Darwin)
        // COPYFILE_CLONE clones the file if possible and will fallback to doing a copy.
        // COPYFILE_ALL is shorthand for:
        //    COPYFILE_STAT | COPYFILE_ACL | COPYFILE_XATTR | COPYFILE_DATA
        let flags = copyfile_flags_t(COPYFILE_CLONE) | copyfile_flags_t(COPYFILE_ALL)
        return Libc.copyfile(
            from: sourcePath,
            to: destinationPath,
            state: nil,
            flags: flags
        ).mapError { errno in
            FileSystemError.fcopyfile(
                errno: errno,
                from: sourcePath,
                to: destinationPath,
                location: .here()
            )
        }

        #elseif canImport(Glibc) || canImport(Musl) || canImport(Bionic)

        let openSourceResult = self._openFile(
            forReadingAt: sourcePath,
            options: OpenOptions.Read(followSymbolicLinks: true)
        ).mapError {
            FileSystemError(
                message: "Can't copy '\(sourcePath)', it couldn't be opened.",
                wrapping: $0
            )
        }

        let source: ReadFileHandle
        switch openSourceResult {
        case let .success(handle):
            source = handle
        case let .failure(error):
            return .failure(error)

Review comment (bug):
Can you update this helper? One of the things it'll do is attach a `SyscallError` to the `FileSystemError` which will include the name of the syscall, now it will incorrectly be `fcopyfile`. 

Where it doesn't make sense to duplicate the helper I've tended to just pass in the name of the syscall: `FileSystemError.copyfile("copyfile", ... )`

Code after:
        to destinationPath: FilePath
    ) -> Result<Void, FileSystemError> {
        func makeOnUnavailableError(
            path: FilePath,
            location: FileSystemError.SourceLocation
        ) -> FileSystemError {
            FileSystemError(
                code: .closed,
                message: "Can't copy '\(sourcePath)' to '\(destinationPath)', '\(path)' is closed.",
                cause: nil,
                location: location
            )
        }

        #if canImport(Darwin)
        // COPYFILE_CLONE clones the file if possible and will fallback to doing a copy.
        // COPYFILE_ALL is shorthand for:
        //    COPYFILE_STAT | COPYFILE_ACL | COPYFILE_XATTR | COPYFILE_DATA
        let flags = copyfile_flags_t(COPYFILE_CLONE) | copyfile_flags_t(COPYFILE_ALL)
        return Libc.copyfile(
            from: sourcePath,
            to: destinationPath,
            state: nil,
            flags: flags
        ).mapError { errno in
            FileSystemError.copyfile(
                errno: errno,
                from: sourcePath,
                to: destinationPath,
                location: .here()
            )
        }

        #elseif canImport(Glibc) || canImport(Musl) || canImport(Bionic)

        let openSourceResult = self._openFile(
            forReadingAt: sourcePath,
            options: OpenOptions.Read(followSymbolicLinks: true)
        ).mapError {
            FileSystemError(
                message: "Can't copy '\(sourcePath)', it couldn't be opened.",
                wrapping: $0
            )
        }

        let source: ReadFileHandle
        switch openSourceResult {
        case let .success(handle):
            source = handle
        case let .failure(error):
            return .failure(error)