mirror of
https://github.com/Llewellynvdm/exa.git
synced 2025-02-04 19:48:25 +00:00
Move file mode constants to a private module
This commit is contained in:
parent
d083d26eaf
commit
48d1e5164c
73
src/file.rs
73
src/file.rs
@ -4,7 +4,6 @@ use std::ascii::AsciiExt;
|
|||||||
use std::env::current_dir;
|
use std::env::current_dir;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::os::unix::raw;
|
|
||||||
use std::os::unix::fs::{MetadataExt, PermissionsExt};
|
use std::os::unix::fs::{MetadataExt, PermissionsExt};
|
||||||
use std::path::{Component, Path, PathBuf};
|
use std::path::{Component, Path, PathBuf};
|
||||||
|
|
||||||
@ -18,35 +17,31 @@ use self::fields as f;
|
|||||||
// Constant table copied from https://doc.rust-lang.org/src/std/sys/unix/ext/fs.rs.html#11-259
|
// Constant table copied from https://doc.rust-lang.org/src/std/sys/unix/ext/fs.rs.html#11-259
|
||||||
// which is currently unstable and lacks vision for stabilization,
|
// which is currently unstable and lacks vision for stabilization,
|
||||||
// see https://github.com/rust-lang/rust/issues/27712
|
// see https://github.com/rust-lang/rust/issues/27712
|
||||||
const USER_READ: raw::mode_t = 0o400;
|
|
||||||
const USER_WRITE: raw::mode_t = 0o200;
|
|
||||||
const USER_EXECUTE: raw::mode_t = 0o100;
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
const USER_RWX: raw::mode_t = 0o700;
|
mod modes {
|
||||||
const GROUP_READ: raw::mode_t = 0o040;
|
use std::os::unix::raw;
|
||||||
const GROUP_WRITE: raw::mode_t = 0o020;
|
|
||||||
const GROUP_EXECUTE: raw::mode_t = 0o010;
|
pub const USER_READ: raw::mode_t = 0o400;
|
||||||
#[allow(dead_code)]
|
pub const USER_WRITE: raw::mode_t = 0o200;
|
||||||
const GROUP_RWX: raw::mode_t = 0o070;
|
pub const USER_EXECUTE: raw::mode_t = 0o100;
|
||||||
const OTHER_READ: raw::mode_t = 0o004;
|
pub const USER_RWX: raw::mode_t = 0o700;
|
||||||
const OTHER_WRITE: raw::mode_t = 0o002;
|
pub const GROUP_READ: raw::mode_t = 0o040;
|
||||||
const OTHER_EXECUTE: raw::mode_t = 0o001;
|
pub const GROUP_WRITE: raw::mode_t = 0o020;
|
||||||
#[allow(dead_code)]
|
pub const GROUP_EXECUTE: raw::mode_t = 0o010;
|
||||||
const OTHER_RWX: raw::mode_t = 0o007;
|
pub const GROUP_RWX: raw::mode_t = 0o070;
|
||||||
#[allow(dead_code)]
|
pub const OTHER_READ: raw::mode_t = 0o004;
|
||||||
const ALL_READ: raw::mode_t = 0o444;
|
pub const OTHER_WRITE: raw::mode_t = 0o002;
|
||||||
#[allow(dead_code)]
|
pub const OTHER_EXECUTE: raw::mode_t = 0o001;
|
||||||
const ALL_WRITE: raw::mode_t = 0o222;
|
pub const OTHER_RWX: raw::mode_t = 0o007;
|
||||||
#[allow(dead_code)]
|
pub const ALL_READ: raw::mode_t = 0o444;
|
||||||
const ALL_EXECUTE: raw::mode_t = 0o111;
|
pub const ALL_WRITE: raw::mode_t = 0o222;
|
||||||
#[allow(dead_code)]
|
pub const ALL_EXECUTE: raw::mode_t = 0o111;
|
||||||
const ALL_RWX: raw::mode_t = 0o777;
|
pub const ALL_RWX: raw::mode_t = 0o777;
|
||||||
#[allow(dead_code)]
|
pub const SETUID: raw::mode_t = 0o4000;
|
||||||
const SETUID: raw::mode_t = 0o4000;
|
pub const SETGID: raw::mode_t = 0o2000;
|
||||||
#[allow(dead_code)]
|
pub const STICKY_BIT: raw::mode_t = 0o1000;
|
||||||
const SETGID: raw::mode_t = 0o2000;
|
}
|
||||||
#[allow(dead_code)]
|
|
||||||
const STICKY_BIT: raw::mode_t = 0o1000;
|
|
||||||
|
|
||||||
|
|
||||||
/// A **File** is a wrapper around one of Rust's Path objects, along with
|
/// A **File** is a wrapper around one of Rust's Path objects, along with
|
||||||
@ -137,7 +132,7 @@ impl<'dir> File<'dir> {
|
|||||||
/// current user. Executable files have different semantics than
|
/// current user. Executable files have different semantics than
|
||||||
/// executable directories, and so should be highlighted differently.
|
/// executable directories, and so should be highlighted differently.
|
||||||
pub fn is_executable_file(&self) -> bool {
|
pub fn is_executable_file(&self) -> bool {
|
||||||
let bit = USER_EXECUTE;
|
let bit = modes::USER_EXECUTE;
|
||||||
self.is_file() && (self.metadata.permissions().mode() & bit) == bit
|
self.is_file() && (self.metadata.permissions().mode() & bit) == bit
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,15 +326,15 @@ impl<'dir> File<'dir> {
|
|||||||
|
|
||||||
f::Permissions {
|
f::Permissions {
|
||||||
file_type: self.type_char(),
|
file_type: self.type_char(),
|
||||||
user_read: has_bit(USER_READ),
|
user_read: has_bit(modes::USER_READ),
|
||||||
user_write: has_bit(USER_WRITE),
|
user_write: has_bit(modes::USER_WRITE),
|
||||||
user_execute: has_bit(USER_EXECUTE),
|
user_execute: has_bit(modes::USER_EXECUTE),
|
||||||
group_read: has_bit(GROUP_READ),
|
group_read: has_bit(modes::GROUP_READ),
|
||||||
group_write: has_bit(GROUP_WRITE),
|
group_write: has_bit(modes::GROUP_WRITE),
|
||||||
group_execute: has_bit(GROUP_EXECUTE),
|
group_execute: has_bit(modes::GROUP_EXECUTE),
|
||||||
other_read: has_bit(OTHER_READ),
|
other_read: has_bit(modes::OTHER_READ),
|
||||||
other_write: has_bit(OTHER_WRITE),
|
other_write: has_bit(modes::OTHER_WRITE),
|
||||||
other_execute: has_bit(OTHER_EXECUTE),
|
other_execute: has_bit(modes::OTHER_EXECUTE),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user