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

Function which

src/phpcs.rs:109–120  ·  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

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

Callers 1

auto_detectFunction · 0.70

Calls 1

is_executableFunction · 0.70

Tested by

no test coverage detected