mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-31 21:17:46 +00:00
std::os changes
This commit is contained in:
parent
09f223fdb1
commit
fd2b464a6d
5 changed files with 9 additions and 11 deletions
|
@ -126,9 +126,7 @@ fn set_context(root: &Path, options: &getopts::Matches) {
|
|||
|
||||
fn enter_chroot(root: &Path) {
|
||||
let root_str = root.display();
|
||||
if !std::os::change_dir(root) {
|
||||
crash!(1, "cannot chdir to {}", root_str)
|
||||
};
|
||||
std::os::change_dir(root).unwrap();
|
||||
let err = unsafe {
|
||||
chroot(".".to_c_str().unwrap() as *const libc::c_char)
|
||||
};
|
||||
|
|
|
@ -168,12 +168,12 @@ pub fn paths_refer_to_same_file(p1: &Path, p2: &Path) -> io::IoResult<bool> {
|
|||
if p1_lstat.kind == io::TypeSymlink {
|
||||
raw_p1 = fs::readlink(&raw_p1).unwrap();
|
||||
}
|
||||
raw_p1 = os::make_absolute(&raw_p1);
|
||||
raw_p1 = os::make_absolute(&raw_p1).unwrap();
|
||||
|
||||
if p2_lstat.kind == io::TypeSymlink {
|
||||
raw_p2 = fs::readlink(&raw_p2).unwrap();
|
||||
}
|
||||
raw_p2 = os::make_absolute(&raw_p2);
|
||||
raw_p2 = os::make_absolute(&raw_p2).unwrap();
|
||||
|
||||
Ok(raw_p1 == raw_p2)
|
||||
}
|
||||
|
|
|
@ -318,7 +318,7 @@ fn rename(from: &Path, to: &Path, b: &Behaviour) -> IoResult<()> {
|
|||
fn read_yes() -> bool {
|
||||
match BufferedReader::new(stdin_raw()).read_line() {
|
||||
Ok(s) => match s.as_slice().slice_shift_char() {
|
||||
(Some(x), _) => x == 'y' || x == 'Y',
|
||||
Some((x, _)) => x == 'y' || x == 'Y',
|
||||
_ => false
|
||||
},
|
||||
_ => false
|
||||
|
|
|
@ -62,7 +62,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
|
||||
fn resolve_path(path: &str, strip: bool, zero: bool, quiet: bool) -> bool {
|
||||
let p = Path::new(path);
|
||||
let abs = std::os::make_absolute(&p);
|
||||
let abs = std::os::make_absolute(&p).unwrap();
|
||||
|
||||
if strip {
|
||||
if zero {
|
||||
|
|
|
@ -50,14 +50,14 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
let from = if opts.free.len() > 1 {
|
||||
Path::new(opts.free[1].as_slice())
|
||||
} else {
|
||||
std::os::getcwd()
|
||||
std::os::getcwd().unwrap()
|
||||
};
|
||||
let absto = std::os::make_absolute(&to);
|
||||
let absfrom = std::os::make_absolute(&from);
|
||||
let absto = std::os::make_absolute(&to).unwrap();
|
||||
let absfrom = std::os::make_absolute(&from).unwrap();
|
||||
|
||||
if opts.opt_present("d") {
|
||||
let base = Path::new(opts.opt_str("d").unwrap());
|
||||
let absbase = std::os::make_absolute(&base);
|
||||
let absbase = std::os::make_absolute(&base).unwrap();
|
||||
if !absbase.is_ancestor_of(&absto) || !absbase.is_ancestor_of(&absfrom) {
|
||||
println!("{}", absto.display());
|
||||
return 0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue