rust/hg-core/src/utils/files.rs
changeset 42437 9609430d3625
child 42484 f305f1d7d559
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rust/hg-core/src/utils/files.rs	Thu Jun 06 15:30:56 2019 +0200
@@ -0,0 +1,17 @@
+use std::path::Path;
+
+pub fn get_path_from_bytes(bytes: &[u8]) -> &Path {
+    let os_str;
+    #[cfg(unix)]
+    {
+        use std::os::unix::ffi::OsStrExt;
+        os_str = std::ffi::OsStr::from_bytes(bytes);
+    }
+    #[cfg(windows)]
+    {
+        use std::os::windows::ffi::OsStrExt;
+        os_str = std::ffi::OsString::from_wide(bytes);
+    }
+
+    Path::new(os_str)
+}