megenginelite_rs/
utils.rs

1use std::ffi::CString;
2use std::path::Path;
3
4pub fn path_to_cstr(path: &Path) -> CString {
5    #[cfg(unix)]
6    let bytes = {
7        use std::os::unix::ffi::OsStrExt;
8
9        path.as_os_str().as_bytes()
10    };
11
12    #[cfg(not(unix))]
13    let bytes = { path.to_string_lossy().to_string().into_bytes() };
14
15    CString::new(bytes).unwrap()
16}