disable backend if binary does not exist

This commit is contained in:
steven-omaha
2023-02-28 13:06:48 +01:00
parent b524840bc9
commit 362658e909
2 changed files with 28 additions and 9 deletions
+11
View File
@@ -65,3 +65,14 @@ pub fn get_config_path_old_version() -> Result<PathBuf> {
file.push(CONFIG_FILE_NAME_OLD);
Ok(file)
}
pub(crate) fn binary_in_path(name: &str) -> Result<bool> {
let paths = env::var_os("PATH").context("getting $PATH")?;
for dir in env::split_paths(&paths) {
let full_path = dir.join(name);
if full_path.is_file() {
return Ok(true);
}
}
Ok(false)
}