use std::ffi::OsStr;
pub(crate) fn starts_with(full: &OsStr, start: &OsStr) -> bool {
#[cfg(unix)]
{
use std::os::unix::ffi::OsStrExt;
return full
.as_bytes()
.starts_with(start.as_bytes());
}
#[cfg(windows)]
{
use std::os::windows::ffi::OsStrExt;
let mut full_units = full.encode_wide();
for start_unit in start.encode_wide() {
if full_units.next() != Some(start_unit) {
return false;
}
}
true
}
}
pub(crate) fn split_on_dot<'a>(value: &'a OsStr) -> Vec<&'a OsStr> {
value
.as_encoded_bytes()
.split(|byte| *byte == b'.')
.map(|part| {
unsafe { OsStr::from_encoded_bytes_unchecked(part) }
})
.collect()
}