Skip to content

Commit 6ca40bc

Browse files
committed
♻️ use nix::sys::stat::lstat instead of libc::lstat
1 parent 70781ac commit 6ca40bc

1 file changed

Lines changed: 1 addition & 6 deletions

File tree

  • cli/src/utils/os/unix

cli/src/utils/os/unix/fs.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,7 @@ pub(crate) fn chmod(path: &Path, mode: u16) -> io::Result<()> {
2222

2323
#[cfg(target_os = "macos")]
2424
pub(crate) fn get_flags(path: &Path) -> io::Result<Vec<String>> {
25-
use std::os::unix::ffi::OsStrExt;
26-
let c_path = std::ffi::CString::new(path.as_os_str().as_bytes())?;
27-
let mut stat: libc::stat = unsafe { std::mem::zeroed() };
28-
if unsafe { libc::lstat(c_path.as_ptr(), &mut stat) } != 0 {
29-
return Err(io::Error::last_os_error());
30-
}
25+
let stat = nix::sys::stat::lstat(path)?;
3126
let flags = stat.st_flags;
3227
let mut flag_names = Vec::new();
3328
if flags & libc::UF_NODUMP != 0 {

0 commit comments

Comments
 (0)