cargo_deb/util/
pathbytes.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#[cfg(unix)]
use std::os::unix::ffi::OsStrExt;
use std::path::Path;

pub trait AsUnixPathBytes {
    fn to_bytes(&self) -> &[u8];
}

impl AsUnixPathBytes for Path {
    #[cfg(not(unix))]
    fn to_bytes(&self) -> &[u8] {
        self.to_str().unwrap().as_bytes()
    }

    #[cfg(unix)]
    fn to_bytes(&self) -> &[u8] {
        self.as_os_str().as_bytes()
    }
}