use std::{
ffi::OsStr,
fs::File,
io,
os::{fd::AsRawFd, unix::ffi::OsStrExt},
path::Path,
};
pub fn exact_name(file: &File, name: &OsStr) -> io::Result<bool> {
let path = rustix::fs::getpath(file)?;
Ok(Path::new(OsStr::from_bytes(path.to_bytes())).file_name() == Some(name))
}
pub fn case_sensitive(directory: &File) -> io::Result<bool> {
let sensitive = unsafe { libc::fpathconf(directory.as_raw_fd(), libc::_PC_CASE_SENSITIVE) };
if sensitive == -1 {
return Err(io::Error::last_os_error());
}
Ok(sensitive != 0)
}