MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / collect_files_relative

Function collect_files_relative

build.rs:320–340  ·  view source on GitHub ↗

Recursively collects every file under `root`, relative to `root`, using forward-slash separators. Returns sorted paths so codegen is deterministic.

(root: &Path)

Source from the content-addressed store, hash-verified

318/// Recursively collects every file under `root`, relative to `root`, using
319/// forward-slash separators. Returns sorted paths so codegen is deterministic.
320fn collect_files_relative(root: &Path) -> Vec<String> {
321 fn walk(base: &Path, dir: &Path, out: &mut Vec<String>) {
322 let Ok(entries) = fs::read_dir(dir) else {
323 return;
324 };
325 for entry in entries.flatten() {
326 let path = entry.path();
327 if path.is_dir() {
328 walk(base, &path, out);
329 } else if path.is_file() {
330 if let Ok(relative) = path.strip_prefix(base) {
331 out.push(relative.to_string_lossy().replace('\\', "/"));
332 }
333 }
334 }
335 }
336 let mut files = Vec::new();
337 walk(root, root, &mut files);
338 files.sort();
339 files
340}
341
342/// True when `path` is a readable UTF-8 text file. Used to fail the skill
343/// bundle codegen early with a clear message when a binary support file would

Callers 1

generate_skill_bundleFunction · 0.85

Calls 1

walkFunction · 0.70

Tested by

no test coverage detected