1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-08-02 14:07:46 +00:00

Use non-PathExt canonicalize().

This commit is contained in:
Joseph Crail 2015-07-31 13:59:37 -04:00
parent f03b22a65c
commit 6ff576e300
4 changed files with 14 additions and 14 deletions

View file

@ -1,5 +1,5 @@
#![crate_name = "cp"]
#![feature(path_ext)]
#![feature(fs_canonicalize)]
/*
* This file is part of the uutils coreutils package.
@ -155,8 +155,8 @@ fn copy(matches: getopts::Matches) {
pub fn paths_refer_to_same_file(p1: &Path, p2: &Path) -> Result<bool> {
// We have to take symlinks and relative paths into account.
let pathbuf1 = try!(p1.canonicalize());
let pathbuf2 = try!(p2.canonicalize());
let pathbuf1 = try!(fs::canonicalize(p1));
let pathbuf2 = try!(fs::canonicalize(p2));
Ok(pathbuf1 == pathbuf2)
}

View file

@ -1,5 +1,5 @@
#![crate_name= "realpath"]
#![feature(path_ext)]
#![feature(fs_canonicalize)]
/*
* This file is part of the uutils coreutils package.
@ -13,7 +13,7 @@
extern crate getopts;
extern crate libc;
use std::fs::PathExt;
use std::fs;
use std::io::Write;
use std::path::{Path, PathBuf};
@ -63,7 +63,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
fn resolve_path(path: &str, strip: bool, zero: bool, quiet: bool) -> bool {
let p = Path::new(path).to_path_buf();
let abs = p.canonicalize().unwrap();
let abs = fs::canonicalize(p).unwrap();
if strip {
if zero {

View file

@ -1,5 +1,5 @@
#![crate_name = "relpath"]
#![feature(path_ext)]
#![feature(fs_canonicalize)]
/*
* This file is part of the uutils coreutils package.
@ -14,7 +14,7 @@ extern crate getopts;
extern crate libc;
use std::env;
use std::fs::PathExt;
use std::fs;
use std::io::Write;
use std::path::{Path, PathBuf};
@ -54,12 +54,12 @@ pub fn uumain(args: Vec<String>) -> i32 {
} else {
env::current_dir().unwrap()
};
let absto = to.canonicalize().unwrap();
let absfrom = from.canonicalize().unwrap();
let absto = fs::canonicalize(to).unwrap();
let absfrom = fs::canonicalize(from).unwrap();
if matches.opt_present("d") {
let base = Path::new(&matches.opt_str("d").unwrap()).to_path_buf();
let absbase = base.canonicalize().unwrap();
let absbase = fs::canonicalize(base).unwrap();
if !absto.as_path().starts_with(absbase.as_path()) || !absfrom.as_path().starts_with(absbase.as_path()) {
println!("{}", absto.display());
return 0

View file

@ -1,5 +1,5 @@
#![crate_name = "stdbuf"]
#![feature(negate_unsigned, path_ext)]
#![feature(fs_canonicalize, negate_unsigned)]
/*
* This file is part of the uutils coreutils package.
@ -15,7 +15,7 @@ extern crate libc;
use getopts::{Matches, Options};
use std::env;
use std::fs::PathExt;
use std::fs;
use std::io::{self, Write};
use std::os::unix::process::ExitStatusExt;
use std::path::PathBuf;
@ -195,7 +195,7 @@ fn set_command_env(command: &mut Command, buffer_name: &str, buffer_type: Buffer
fn exe_path() -> io::Result<PathBuf> {
let exe_path = try!(env::current_exe());
let absolute_path = try!(exe_path.as_path().canonicalize());
let absolute_path = try!(fs::canonicalize(exe_path.as_path()));
Ok(match absolute_path.parent() {
Some(p) => p.to_path_buf(),
None => absolute_path.clone()