| 1 | use std::path::Path; |
| 2 | use std::ffi::{CStr, CString, OsStr}; |
| 3 | use std::os::unix::ffi::OsStrExt; |
| 4 | |
| 5 | |
| 6 | pub fn path_to_cstring(path: &Path) -> CString { |
| 7 | return CString::new(path.as_os_str().as_bytes()).unwrap() |
| 8 | } |
| 9 | |
| 10 | pub fn as_path(cstring: &CStr) -> &Path { |
| 11 | OsStr::from_bytes(cstring.to_bytes()).as_ref() |
| 12 | } |