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

Function which

src/phpstan.rs:107–118  ·  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

105/// Simple `which`-like lookup: search `$PATH` for an executable with
106/// the given name.
107fn which(binary_name: &str) -> Result<PathBuf, String> {
108 let path_var = std::env::var("PATH").map_err(|_| "PATH not set".to_string())?;
109
110 for dir in std::env::split_paths(&path_var) {
111 let candidate = dir.join(binary_name);
112 if candidate.is_file() && is_executable(&candidate) {
113 return Ok(candidate);
114 }
115 }
116
117 Err(format!("{} not found on PATH", binary_name))
118}
119
120/// Check whether a file is executable.
121#[cfg(unix)]

Callers 1

auto_detectFunction · 0.70

Calls 1

is_executableFunction · 0.70

Tested by

no test coverage detected