use posish::fs::getpath;
use std::{fs, os::unix::ffi::OsStringExt, path::PathBuf};
pub(crate) fn file_path(file: &fs::File) -> Option<PathBuf> {
let mut buf = vec![0; libc::PATH_MAX as usize];
getpath(file, &mut buf).ok()?;
let l = buf.iter().position(|&c| c == 0).unwrap();
buf.truncate(l as usize);
buf.shrink_to_fit();
Some(PathBuf::from(std::ffi::OsString::from_vec(buf)))
}