INNER CODE UNIT · Swift

indexSharedSources

21-DOT-DEV/swift-secp256k1 · Scripts/rewrite-docc-shared-paths.swift:76

func indexSharedSources(at root: URL) throws -> [String: String] {
    guard let enumerator = FileManager.default.enumerator(
        at: root,
        includingPropertiesForKeys: [.isRegularFileKey],
        options: [.skipsHiddenFiles]
    ) else {
        throw ScriptError(description: "failed to enumerate \(root.path)")
    }

    let cwd = FileManager.default.currentDirectoryPath + "/"
    var index: [String: String] = [:]
    for case let url as URL in enumerator where url.pathExtension == "swift" {
        let basename = url.lastPathComponent
        let absolute = url.standardizedFileURL.path
        let relative = absolute.hasPrefix(cwd) ? String(absolute.dropFirst(cwd.count)) : absolute
        if let existing = index[basename] {
            throw ScriptError(
                description:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…