use std::fs;
use std::path::Path;
#[cfg(not(windows))]
use uucore::mode;
pub fn parse(mode_string: &str, considering_dir: bool, umask: u32) -> Result<u32, String> {
let numbers: &[char] = &['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
if mode_string.contains(numbers) {
mode::parse_numeric(0, mode_string, considering_dir)
} else {
mode::parse_symbolic(0, mode_string, umask, considering_dir)
}
}
#[cfg(any(unix, target_os = "redox"))]
pub fn chmod(path: &Path, mode: u32) -> Result<(), ()> {
use std::os::unix::fs::PermissionsExt;
use uucore::{display::Quotable, show_error};
fs::set_permissions(path, fs::Permissions::from_mode(mode)).map_err(|err| {
show_error!("{}: chmod failed with error {}", path.maybe_quote(), err);
})
}
#[cfg(windows)]
pub fn chmod(path: &Path, mode: u32) -> Result<(), ()> {
Ok(())
}