Skip to content

Commit

Permalink
Fix withTemporaryDirectory compilation on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
kateinoigakukun committed Jul 1, 2024
1 parent f2f70f1 commit f569b0b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Tests/WITExtractorTests/TestSupport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,18 @@ struct TestSupport {
let templatePath = tempdir.appendingPathComponent("WasmKit.XXXXXX")
var template = [UInt8](templatePath.path.utf8).map({ Int8($0) }) + [Int8(0)]

#if os(Windows)
if _mktemp_s(&template, template.count) != 0 {
throw Error(errno: errno)
}
if _mkdir(template) != 0 {
throw Error(errno: errno)
}
#else
if mkdtemp(&template) == nil {
throw Error(errno: errno)
}
#endif

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

0 comments on commit f569b0b

Please sign in to comment.