comparison rust/hg-core/src/utils/files.rs @ 43792:ee3872c14ab3

rust-cpython: do not convert warning pattern to utf-8 bytes On Unix, both Rust Path and Mercurial expect a locale-dependent bytes, and we don't support Windows yet.
author Yuya Nishihara <yuya@tcha.org>
date Tue, 19 Nov 2019 23:19:57 +0900
parents 0b7733719d21
children cf065c6a0197
comparison
equal deleted inserted replaced
43791:f79377f24487 43792:ee3872c14ab3
25 // TODO Handle other platforms 25 // TODO Handle other platforms
26 // TODO: convert from WTF8 to Windows MBCS (ANSI encoding). 26 // TODO: convert from WTF8 to Windows MBCS (ANSI encoding).
27 // Perhaps, the return type would have to be Result<PathBuf>. 27 // Perhaps, the return type would have to be Result<PathBuf>.
28 28
29 Path::new(os_str) 29 Path::new(os_str)
30 }
31
32 // TODO: need to convert from WTF8 to MBCS bytes on Windows.
33 // that's why Vec<u8> is returned.
34 #[cfg(unix)]
35 pub fn get_bytes_from_path(path: impl AsRef<Path>) -> Vec<u8> {
36 use std::os::unix::ffi::OsStrExt;
37 path.as_ref().as_os_str().as_bytes().to_vec()
30 } 38 }
31 39
32 /// An iterator over repository path yielding itself and its ancestors. 40 /// An iterator over repository path yielding itself and its ancestors.
33 #[derive(Copy, Clone, Debug)] 41 #[derive(Copy, Clone, Debug)]
34 pub struct Ancestors<'a> { 42 pub struct Ancestors<'a> {