diff rust/hg-core/src/utils/files.rs @ 46742:91ab5190a3de

rhg: Add support for environment variables in config include paths Some tests rely on this. Differential Revision: https://phab.mercurial-scm.org/D10140
author Simon Sapin <simon.sapin@octobus.net>
date Mon, 08 Mar 2021 15:35:32 +0100
parents d2e61f00ee9d
children 3c9ddb1986a9
line wrap: on
line diff
--- a/rust/hg-core/src/utils/files.rs	Mon Mar 08 08:55:48 2021 +0100
+++ b/rust/hg-core/src/utils/files.rs	Mon Mar 08 15:35:32 2021 +0100
@@ -23,7 +23,7 @@
 use std::ops::Deref;
 use std::path::{Path, PathBuf};
 
-pub fn get_path_from_bytes(bytes: &[u8]) -> &Path {
+pub fn get_os_str_from_bytes(bytes: &[u8]) -> &OsStr {
     let os_str;
     #[cfg(unix)]
     {
@@ -33,8 +33,11 @@
     // TODO Handle other platforms
     // TODO: convert from WTF8 to Windows MBCS (ANSI encoding).
     // Perhaps, the return type would have to be Result<PathBuf>.
+    os_str
+}
 
-    Path::new(os_str)
+pub fn get_path_from_bytes(bytes: &[u8]) -> &Path {
+    Path::new(get_os_str_from_bytes(bytes))
 }
 
 // TODO: need to convert from WTF8 to MBCS bytes on Windows.