use std::path::{Path, PathBuf};
use windows::core::PCWSTR;
pub(crate) fn strip_extended_prefix(path: &Path) -> PathBuf {
let s = path.to_string_lossy();
if let Some(stripped) = s.strip_prefix(r"\\?\") {
PathBuf::from(stripped)
} else {
path.to_path_buf()
}
}
pub(crate) fn path_to_wide(path: &Path) -> Vec<u16> {
use std::os::windows::ffi::OsStrExt;
path.as_os_str()
.encode_wide()
.chain(std::iter::once(0))
.collect()
}
pub(crate) fn wide_to_pcwstr(buf: &[u16]) -> PCWSTR {
PCWSTR(buf.as_ptr())
}
pub(crate) fn ansi_buf_to_string(buf: &[u8]) -> String {
let end = buf.iter().position(|&b| b == 0).unwrap_or(buf.len());
String::from_utf8_lossy(&buf[..end]).into_owned()
}