1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use std::ffi::OsString;
use std::os::windows::ffi::{OsStrExt, OsStringExt};
use std::path::{Path, PathBuf};
use std::{fs, io};
pub(crate) fn get_path(file: &fs::File) -> io::Result<PathBuf> {
let path = winx::file::get_file_path(file)?;
let wide: Vec<_> = path.as_os_str().encode_wide().collect();
let wide_final = if wide.starts_with(&['\\' as u16, '\\' as _, '?' as _, '\\' as _]) {
&wide[4..]
} else {
&wide
};
Ok(PathBuf::from(OsString::from_wide(wide_final)))
}
pub(super) fn concatenate(file: &fs::File, path: &Path) -> io::Result<PathBuf> {
let file_path = get_path(file)?;
Ok(file_path.join(path))
}