Skip to content

Commit 294988f

Browse files
Merge pull request #4896 from kateinoigakukun/pr-d439004e8dc1ebc3653d4dc92c6d1c0d9f0dbb50
[wasm] Provide stub for `_NSCreateTemporaryFile` on WASI
2 parents 06c2eec + ca40780 commit 294988f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Sources/Foundation/NSPathUtilities.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,10 @@ internal func _NSCreateTemporaryFile(_ filePath: String) throws -> (Int32, Strin
779779
}
780780
// Don't close h, fd is transferred ownership
781781
let fd = _open_osfhandle(intptr_t(bitPattern: h), 0)
782+
return (fd, pathResult)
783+
#elseif os(WASI)
784+
// WASI does not have temp directories
785+
throw NSError(domain: NSPOSIXErrorDomain, code: Int(ENOTSUP))
782786
#else
783787
var template = URL(fileURLWithPath: filePath)
784788

@@ -814,8 +818,8 @@ internal func _NSCreateTemporaryFile(_ filePath: String) throws -> (Int32, Strin
814818
close(fd)
815819
throw _NSErrorWithErrno(_errno, reading: false, path: pathResult)
816820
}
817-
#endif
818821
return (fd, pathResult)
822+
#endif
819823
}
820824

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

0 commit comments

Comments
 (0)