Skip to content

Commit 9eccae9

Browse files
committed
[UnicodeData] Create directory when emitting output data
1 parent 0ddc2b2 commit 9eccae9

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

utils/gen-unicode-data/Sources/GenUtils/Files.swift

+10-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,16 @@ public func readFile(_ path: String) -> String {
2222

2323
public func write(_ data: String, to path: String) {
2424
do {
25-
try data.write(toFile: path, atomically: false, encoding: .utf8)
25+
let directory = path.prefix(upTo: path.lastIndex(of: "/") ?? path.endIndex)
26+
try FileManager.default.createDirectory(
27+
atPath: String(directory),
28+
withIntermediateDirectories: true
29+
)
30+
try data.write(
31+
toFile: path,
32+
atomically: false,
33+
encoding: .utf8
34+
)
2635
} catch {
2736
fatalError(error.localizedDescription)
2837
}

0 commit comments

Comments
 (0)