MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / first_existing_path

Function first_existing_path

rust/src/files.rs:83–93  ·  view source on GitHub ↗

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])

Source from the content-addressed store, hash-verified

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.
83pub 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
95pub fn create_parent_path_if_not_exists(path: &Path) -> Result<(), Error> {
96 if let Some(p) = path.parent() {

Calls 1

existsMethod · 0.45

Tested by

no test coverage detected