MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / search_recursive

Function search_recursive

crates/opencode-server/src/routes.rs:3098–3119  ·  view source on GitHub ↗
(
        path: &FsPath,
        root: &FsPath,
        pattern: &str,
        results: &mut Vec<SearchResult>,
    )

Source from the content-addressed store, hash-verified

3096 }
3097
3098 fn search_recursive(
3099 path: &FsPath,
3100 root: &FsPath,
3101 pattern: &str,
3102 results: &mut Vec<SearchResult>,
3103 ) {
3104 if path.is_dir() {
3105 if let Ok(entries) = std::fs::read_dir(path) {
3106 for entry in entries.flatten() {
3107 let path_buf = entry.path();
3108 if !is_within_root(&path_buf, root) {
3109 continue;
3110 }
3111 if path_buf.is_dir() {
3112 search_recursive(&path_buf, root, pattern, results);
3113 } else if path_buf.is_file() {
3114 search_in_file(&path_buf, pattern, results);
3115 }
3116 }
3117 }
3118 }
3119 }
3120
3121 search_recursive(&base_path, &root, &query.pattern, &mut results);
3122 Ok(Json(results))

Callers 1

find_textFunction · 0.85

Calls 4

is_within_rootFunction · 0.85
search_in_fileFunction · 0.85
is_dirMethod · 0.80
is_fileMethod · 0.80

Tested by

no test coverage detected