MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / which

Function which

src/mago.rs:120–131  ·  view source on GitHub ↗

Simple `which`-like lookup: search `$PATH` for an executable with the given name.

(binary_name: &str)

Source from the content-addressed store, hash-verified

118/// Simple `which`-like lookup: search `$PATH` for an executable with
119/// the given name.
120fn which(binary_name: &str) -> Result<PathBuf, String> {
121 let path_var = std::env::var("PATH").map_err(|_| "PATH not set".to_string())?;
122
123 for dir in std::env::split_paths(&path_var) {
124 let candidate = dir.join(binary_name);
125 if candidate.is_file() && is_executable(&candidate) {
126 return Ok(candidate);
127 }
128 }
129
130 Err(format!("{} not found on PATH", binary_name))
131}
132
133/// Check whether a file is executable.
134#[cfg(unix)]

Callers 1

auto_detectFunction · 0.70

Calls 1

is_executableFunction · 0.70

Tested by

no test coverage detected