Skip to content

Commit f569b0b

Browse files
Fix withTemporaryDirectory compilation on Windows
1 parent f2f70f1 commit f569b0b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Tests/WITExtractorTests/TestSupport.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,18 @@ struct TestSupport {
4747
let templatePath = tempdir.appendingPathComponent("WasmKit.XXXXXX")
4848
var template = [UInt8](templatePath.path.utf8).map({ Int8($0) }) + [Int8(0)]
4949

50+
#if os(Windows)
51+
if _mktemp_s(&template, template.count) != 0 {
52+
throw Error(errno: errno)
53+
}
54+
if _mkdir(template) != 0 {
55+
throw Error(errno: errno)
56+
}
57+
#else
5058
if mkdtemp(&template) == nil {
5159
throw Error(errno: errno)
5260
}
61+
#endif
5362

5463
let path = String(cString: template)
5564
defer { _ = try? FileManager.default.removeItem(atPath: path) }

0 commit comments

Comments
 (0)