From 0b291355b286f38ca8fc1a761a5267431d92e795 Mon Sep 17 00:00:00 2001 From: David Adam Date: Thu, 20 Jul 2023 23:35:22 +0800 Subject: [PATCH] wutil: add perror implementation that takes an io::Error --- fish-rust/src/wutil/mod.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fish-rust/src/wutil/mod.rs b/fish-rust/src/wutil/mod.rs index ea652a154..9f118cdb6 100644 --- a/fish-rust/src/wutil/mod.rs +++ b/fish-rust/src/wutil/mod.rs @@ -22,7 +22,7 @@ pub(crate) use gettext::{wgettext, wgettext_fmt, wgettext_str}; pub(crate) use printf::sprintf; use std::ffi::OsStr; use std::fs::{self, canonicalize}; -use std::io::Write; +use std::io::{self, Write}; use std::os::fd::{FromRawFd, IntoRawFd, RawFd}; use std::os::unix::prelude::{OsStrExt, OsStringExt}; @@ -81,6 +81,10 @@ pub fn perror(s: &str) { let _ = stderr.write_all(b"\n"); } +pub fn perror_io(s: &str, e: &io::Error) { + eprintln!("{}: {}", s, e); +} + /// Wide character version of getcwd(). pub fn wgetcwd() -> WString { let mut cwd = [b'\0'; libc::PATH_MAX as usize];