Returns the first ` / ` that exists, searched name-major (every dir tried for a name before moving to the next name), matching how a browser's own driver walks candidates.
(dirs: &[&str], names: &[&str])
| 81 | // Returns the first `<dir>/<name>` that exists, searched name-major (every dir tried for a |
| 82 | // name before moving to the next name), matching how a browser's own driver walks candidates. |
| 83 | pub fn first_existing_path(dirs: &[&str], names: &[&str]) -> Option<PathBuf> { |
| 84 | for name in names { |
| 85 | for dir in dirs { |
| 86 | let candidate = Path::new(dir).join(name); |
| 87 | if candidate.exists() { |
| 88 | return Some(candidate); |
| 89 | } |
| 90 | } |
| 91 | } |
| 92 | None |
| 93 | } |
| 94 | |
| 95 | pub fn create_parent_path_if_not_exists(path: &Path) -> Result<(), Error> { |
| 96 | if let Some(p) = path.parent() { |
no test coverage detected