Skip to content

[wasm] Fix CocoaError construction for unsupported copy/link operations #944

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Sources/FoundationEssentials/FileManager/FileOperations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -920,10 +920,11 @@ enum _FileOperations {
try delegate.throwIfNecessary(errno, src, dst)
return
}
let copyFile = delegate.copyData
guard !stat.isDirectory else {
// wasi-libc does not support FTS for now, so we don't support copying/linking
// directories on WASI for now.
let error = CocoaError.fileOperationError(.featureUnsupported, src, dst)
let error = CocoaError.errorWithFilePath(.featureUnsupported, src, variant: copyFile ? "Copy" : "Link", source: src, destination: dst)
try delegate.throwIfNecessary(error, src, dst)
return
}
Expand All @@ -943,7 +944,7 @@ enum _FileOperations {
try delegate.throwIfNecessary(errno, src, dst)
}
} else {
if delegate.copyData {
if copyFile {
try _copyRegularFile(srcPtr, dstPtr, delegate: delegate)
} else {
if link(srcPtr, dstPtr) != 0 {
Expand Down