wutil: add perror implementation that takes an io::Error

This commit is contained in:
David Adam 2023-07-20 23:35:22 +08:00
parent 3d0b66c825
commit 0b291355b2

View File

@ -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];