firefox-default-path.rs (697B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 extern crate mozrunner; 6 7 use mozrunner::runner::platform; 8 use std::io::Write; 9 10 fn main() { 11 let (path, code) = platform::firefox_default_path() 12 .map(|x| (x.to_string_lossy().into_owned(), 0)) 13 .unwrap_or(("Firefox binary not found".to_owned(), 1)); 14 15 let mut writer: Box<dyn Write> = match code { 16 0 => Box::new(std::io::stdout()), 17 _ => Box::new(std::io::stderr()), 18 }; 19 writeln!(&mut writer, "{}", &*path).unwrap(); 20 std::process::exit(code); 21 }