mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-30 04:27:45 +00:00
commit
ab0a51fcb0
1 changed files with 4 additions and 4 deletions
|
@ -148,11 +148,11 @@ enum PathCondition {
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
fn path(path: &[u8], cond: PathCondition) -> bool {
|
fn path(path: &[u8], cond: PathCondition) -> bool {
|
||||||
use libc::{stat, c_int, lstat, S_IFMT, S_IFLNK, S_IFBLK, S_IFCHR, S_IFDIR, S_IFREG};
|
use libc::{stat, lstat, S_IFMT, S_IFLNK, S_IFBLK, S_IFCHR, S_IFDIR, S_IFREG};
|
||||||
use libc::{S_IFIFO, mode_t};
|
use libc::{S_IFIFO, mode_t};
|
||||||
static S_ISUID: mode_t = 0o4000;
|
static S_ISUID: mode_t = 0o4000;
|
||||||
static S_ISGID: mode_t = 0o2000;
|
static S_ISGID: mode_t = 0o2000;
|
||||||
static S_IFSOCK: c_int = 0o140000;
|
static S_IFSOCK: mode_t = 0o140000;
|
||||||
|
|
||||||
enum Permission {
|
enum Permission {
|
||||||
Read = 0o4,
|
Read = 0o4,
|
||||||
|
@ -175,7 +175,7 @@ fn path(path: &[u8], cond: PathCondition) -> bool {
|
||||||
let mut stat = unsafe { std::mem::zeroed() };
|
let mut stat = unsafe { std::mem::zeroed() };
|
||||||
if cond == SymLink {
|
if cond == SymLink {
|
||||||
if unsafe { lstat(path.as_ptr(), &mut stat) } == 0 {
|
if unsafe { lstat(path.as_ptr(), &mut stat) } == 0 {
|
||||||
if stat.st_mode as c_int & S_IFMT == S_IFLNK {
|
if stat.st_mode & S_IFMT == S_IFLNK {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -184,7 +184,7 @@ fn path(path: &[u8], cond: PathCondition) -> bool {
|
||||||
if unsafe { libc::stat(path.as_ptr(), &mut stat) } != 0 {
|
if unsafe { libc::stat(path.as_ptr(), &mut stat) } != 0 {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let file_type = stat.st_mode as c_int & S_IFMT;
|
let file_type = stat.st_mode & S_IFMT;
|
||||||
match cond {
|
match cond {
|
||||||
BlockSpecial => file_type == S_IFBLK,
|
BlockSpecial => file_type == S_IFBLK,
|
||||||
CharacterSpecial => file_type == S_IFCHR,
|
CharacterSpecial => file_type == S_IFCHR,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue