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

Function expand_glob

crates/opencode-session/src/instruction.rs:127–140  ·  view source on GitHub ↗

Expand a glob pattern rooted at `cwd`, returning absolute paths.

(pattern: &str, cwd: &Path)

Source from the content-addressed store, hash-verified

125
126/// Expand a glob pattern rooted at `cwd`, returning absolute paths.
127fn expand_glob(pattern: &str, cwd: &Path) -> Vec<PathBuf> {
128 let full = if Path::new(pattern).is_absolute() {
129 pattern.to_string()
130 } else {
131 cwd.join(pattern).to_string_lossy().to_string()
132 };
133 match glob::glob(&full) {
134 Ok(paths) => paths
135 .filter_map(|entry| entry.ok())
136 .filter(|p| p.is_file())
137 .collect(),
138 Err(_) => Vec::new(),
139 }
140}
141
142/// Walk up from `start` to `stop`, expanding a glob pattern at each level.
143fn glob_up(pattern: &str, start: &Path, stop: &Path) -> Vec<PathBuf> {

Callers 3

glob_upFunction · 0.85
resolve_config_pathMethod · 0.85
test_glob_expansionFunction · 0.85

Calls 3

newFunction · 0.85
is_fileMethod · 0.80
filterMethod · 0.45

Tested by 1

test_glob_expansionFunction · 0.68