// SPDX-FileCopyrightText: 2025 The Project Pterodactyl Developers // // SPDX-License-Identifier: MPL-2.0 import Foundation import TSCBasic import llbuild2fx extension LLBCASFileTree { func traverse(root: AbsolutePath, in db: any LLBCASDatabase, _ ctx: Context, _ callback: (AbsolutePath, LLBDataID, LLBDirectoryEntry) async throws -> Void) async throws { for (index, fileId) in object.refs.enumerated() { let directoryEntry = files[index] switch directoryEntry.type { case .directory: let root = root.appending(component: directoryEntry.name) let subtree = try await Self.load(id: fileId, from: db, ctx).get() try await subtree.traverse(root: root, in: db, ctx, callback) case .plainFile: try await callback(root.appending(component: directoryEntry.name), fileId, directoryEntry) default: continue } } } }