Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/hop/blob/main/Omega/tests/ui-index/main.swift # hop Hop: a small native macOS launcher. Clipboard history, find, on-device dictation and your coding agent behind one key. Brought by drakestapleton Sign in to star 1 stars 1 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `hop / Omega / tests / ui-index / main.swift` 29 lines ยท 1540 bytes Raw Blame History 1 import Foundation 2 3 // Builds a file index exactly as Hop does: the loop below is the one of Sources/FileIndex.swift (rebuild), given 4 // the folders and the names to skip on the command line. Omega/tests/check-ui.sh compares what it writes, byte 5 // for byte, with what the Omega program writes for the same folders. 6 // ui-index OUT ROOT [SKIP-NAME ...] 7 let a = CommandLine.arguments 8 guard a.count >= 3 else { FileHandle.standardError.write(Data("usage: ui-index OUT ROOT [SKIP-NAME ...]\n".utf8)); exit(2) } 9 let roots = [a[2]], skip = Set(a.dropFirst(3)) 10 var out = Data() 11 let keys: [URLResourceKey] = [.isDirectoryKey, .isPackageKey, .isSymbolicLinkKey] 12 var seen = 0 13 for root in roots { 14 guard let en = FileManager.default.enumerator(at: URL(fileURLWithPath: root), includingPropertiesForKeys: keys, 15 options: [.skipsHiddenFiles], errorHandler: { _, _ in true }) else { continue } 16 for case let u as URL in en { 17 let name = u.lastPathComponent 18 let v = try? u.resourceValues(forKeys: Set(keys)) 19 if v?.isDirectory == true { 20 if skip.contains(name) || v?.isSymbolicLink == true { en.skipDescendants(); continue } 21 if v?.isPackage == true { en.skipDescendants() } // .app, .pages, ... count as one item 22 } 23 out.append(contentsOf: Array(u.path.utf8)); out.append(10) 24 seen += 1 25 if seen >= 3_000_000 { break } 26 } 27 } 28 try! out.write(to: URL(fileURLWithPath: a[1]), options: .atomic) 29 print("indexed \(seen) items")