INNER CODE UNIT · Swift
rewriteArchive
21-DOT-DEV/swift-secp256k1 · Scripts/rewrite-docc-shared-paths.swift:108
func rewriteArchive(at archive: URL, basenames: [String: String]) throws -> RewriteStats {
let dataRoot = archive.appending(path: "data")
guard FileManager.default.fileExists(atPath: dataRoot.path) else {
throw ScriptError(description: "archive data dir not found: \(dataRoot.path)")
}
guard let enumerator = FileManager.default.enumerator(
at: dataRoot,
includingPropertiesForKeys: [.isRegularFileKey],
options: [.skipsHiddenFiles]
) else {
throw ScriptError(description: "failed to enumerate \(dataRoot.path)")
}
var stats = RewriteStats()
for case let fileURL as URL in enumerator where fileURL.pathExtension == "json" {
stats.filesScanned += 1
let original = try String(contentsOf: fileURL, encoding: .utf8)