diff options
Diffstat (limited to 'src/config/mimetype/entry.rs')
-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>, |