fix(opener): return error if path not exists (#2253)

pull/2259/head
Didrik Nordström 5 months ago committed by GitHub
parent 3461a7ae2c
commit a9ac1e3c93
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,6 @@
---
"opener": patch
"opener-js": patch
---
Return an error in `open_path` if the file does not exist when opening with default application.

@ -53,5 +53,9 @@ pub fn open_url<P: AsRef<str>, S: AsRef<str>>(url: P, with: Option<S>) -> crate:
/// ```
pub fn open_path<P: AsRef<Path>, S: AsRef<str>>(path: P, with: Option<S>) -> crate::Result<()> {
let path = path.as_ref();
if with.is_none() {
// Returns an IO error if not exists, and besides `exists()` is a shorthand for `metadata()`
_ = path.metadata()?;
}
open(path, with)
}

Loading…
Cancel
Save