pacenotes_installer\selftest/report.rs
1/// Exit code when the report itself could not be written.
2const REPORT_UNWRITABLE: i32 = 2;
3
4/// Writes `report` to `out`, or shows it when there is none, and returns
5/// `exit_code` unless the file could not be written.
6pub fn deliver(out: Option<&std::path::Path>, report: &str, exit_code: i32) -> i32 {
7 match out {
8 Some(path) => {
9 if std::fs::write(path, report).is_err() {
10 crate::ui::message_box_error(
11 core::ptr::null_mut(),
12 &format!("Cannot write {}", path.display()),
13 );
14 return REPORT_UNWRITABLE;
15 }
16 }
17 None => crate::ui::message_box_info(core::ptr::null_mut(), report),
18 }
19 exit_code
20}