| 225 | } |
| 226 | |
| 227 | fn resolve_driver_search_dirs(vm_config: &VmComputeConfig) -> Vec<PathBuf> { |
| 228 | vm_config.driver_dir.clone().map_or_else( |
| 229 | || { |
| 230 | let mut dirs = Vec::new(); |
| 231 | if let Ok(current_exe) = std::env::current_exe() |
| 232 | && let Some(prefix) = current_exe.parent().and_then(Path::parent) |
| 233 | { |
| 234 | push_unique_path(&mut dirs, prefix.join("libexec")); |
| 235 | push_unique_path(&mut dirs, prefix.join("libexec").join("openshell")); |
| 236 | } |
| 237 | for dir in VmComputeConfig::default_driver_search_dirs( |
| 238 | std::env::var_os("HOME").map(PathBuf::from), |
| 239 | ) { |
| 240 | push_unique_path(&mut dirs, dir); |
| 241 | } |
| 242 | dirs |
| 243 | }, |
| 244 | |dir| vec![dir], |
| 245 | ) |
| 246 | } |
| 247 | |
| 248 | fn push_unique_path(paths: &mut Vec<PathBuf>, path: PathBuf) { |
| 249 | if !paths.iter().any(|existing| existing == &path) { |