Skip to content
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

[wasm] Provide stub for _NSCreateTemporaryFile on WASI #4896

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion Sources/Foundation/NSPathUtilities.swift
Expand Up @@ -779,6 +779,10 @@ internal func _NSCreateTemporaryFile(_ filePath: String) throws -> (Int32, Strin
}
// Don't close h, fd is transferred ownership
let fd = _open_osfhandle(intptr_t(bitPattern: h), 0)
return (fd, pathResult)
#elseif os(WASI)
// WASI does not have temp directories
throw NSError(domain: NSPOSIXErrorDomain, code: Int(ENOTSUP))
#else
var template = URL(fileURLWithPath: filePath)

Expand Down Expand Up @@ -814,8 +818,8 @@ internal func _NSCreateTemporaryFile(_ filePath: String) throws -> (Int32, Strin
close(fd)
throw _NSErrorWithErrno(_errno, reading: false, path: pathResult)
}
#endif
return (fd, pathResult)
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change seems to be impacting non-WASI #if branch?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return (fd, pathResult) line was shared among all cases, but it's now cloned into os(Windows) and !os(Windows) && !os(WASI) cases. So there is no semantic change.

}

internal func _NSCleanupTemporaryFile(_ auxFilePath: String, _ filePath: String) throws {
Expand Down