Skip to content

Commit

Permalink
Use libc's F_GETPATH
Browse files Browse the repository at this point in the history
  • Loading branch information
evilpie committed Dec 27, 2024
1 parent 712b698 commit 4060b4e
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,12 @@ impl FilePath for File {
fn path(&self) -> io::Result<PathBuf> {
use std::ffi::OsString;
use std::os::unix::ffi::OsStringExt;
const F_GETPATH: i32 = 50;

let fd = self.as_raw_fd();
let mut path = vec![0; libc::PATH_MAX as usize + 1];

unsafe {
if libc::fcntl(fd, F_GETPATH, path.as_mut_ptr()) < 0 {
if libc::fcntl(fd, libc::F_GETPATH, path.as_mut_ptr()) < 0 {
return Err(io::Error::last_os_error());
}
}
Expand Down

0 comments on commit 4060b4e

Please sign in to comment.