diff options
author | sushi-shi <47691267+sushi-shi@users.noreply.github.com> | 2022-03-02 21:31:06 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-02 13:31:06 -0500 |
commit | 32ccec90bb41e83651a803229068007c6bb31a93 (patch) | |
tree | 3205afc6a36f7a089dc6171cd4cc93421e13f62d /src/config/mimetype | |
parent | 7c6bb9ca1b3d7fb61a4cfc5c997ae0e247bd5acc (diff) |
Try all options when opening files (#150)
Diffstat (limited to 'src/config/mimetype')
-rw-r--r-- | src/config/mimetype/entry.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/config/mimetype/entry.rs b/src/config/mimetype/entry.rs index 6a85b0e..bf65e59 100644 --- a/src/config/mimetype/entry.rs +++ b/src/config/mimetype/entry.rs @@ -1,4 +1,5 @@ use serde_derive::Deserialize; +use std::env; use std::fmt; use std::io::Read; use std::process; @@ -106,6 +107,14 @@ impl AppMimetypeEntry { self._confirm_exit } + // TODO: Windows support + pub fn program_exists(&self) -> bool { + let program = self.get_command(); + env::var_os("PATH") + .map(|path| env::split_paths(&path).any(|dir| dir.join(program).is_file())) + .unwrap_or(false) + } + pub fn execute_with<I, S>(&self, paths: I) -> std::io::Result<()> where I: IntoIterator<Item = S>, |