From 22500b8d718f703694186a0fcc4b83ff040fd562 Mon Sep 17 00:00:00 2001 From: Kenta Kubo <601636+kkebo@users.noreply.github.com> Date: Sat, 19 Oct 2024 22:55:53 +0900 Subject: [PATCH] [wasm] Make `FileManager.createFile()` work on WASI fixes swiftwasm/swift#5593 `FileManager.createFile()` currently doesn't work on WASI because it requires `.atomic`, it requires creating a temporary file, and it isn't suppported on WASI. So I have fixed that by removing the `.atomic` requirement only on WASI. --- .../FoundationEssentials/FileManager/FileManager+Files.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sources/FoundationEssentials/FileManager/FileManager+Files.swift b/Sources/FoundationEssentials/FileManager/FileManager+Files.swift index 6e1799506..abf6e31a1 100644 --- a/Sources/FoundationEssentials/FileManager/FileManager+Files.swift +++ b/Sources/FoundationEssentials/FileManager/FileManager+Files.swift @@ -276,6 +276,9 @@ extension _FileManagerImpl { } attr?[.protectionKey] = nil } + #elseif os(WASI) + // WASI doesn't support a temporary file, so can't use `.atomic` + let opts: Data.WritingOptions = [] #else let opts = Data.WritingOptions.atomic #endif