locate_dwarf/
path_utils.rs

1use anyhow::Error;
2
3cfg_if::cfg_if! {
4    if #[cfg(unix)] {
5        use std::ffi::OsStr;
6        use std::os::unix::ffi::OsStrExt;
7
8        #[allow(clippy::unnecessary_wraps)]
9        pub fn path_from_bytes(bytes: &[u8]) -> Result<&OsStr, Error> {
10            Ok(OsStr::from_bytes(bytes))
11        }
12    } else {
13        use std::str;
14
15        pub fn path_from_bytes(bytes: &[u8]) -> Result<&str, str::Utf8Error> {
16            str::from_utf8(bytes)
17        }
18    }
19}