diff --git a/src/link/link.rs b/src/link/link.rs index 4454a9fe4..6a4b2f013 100644 --- a/src/link/link.rs +++ b/src/link/link.rs @@ -1,5 +1,5 @@ #![crate_name = "link"] -#![feature(collections, core, old_io, old_path, rustc_private)] +#![feature(rustc_private)] /* * This file is part of the uutils coreutils package. @@ -12,8 +12,9 @@ extern crate getopts; -use std::old_io::fs::link; -use std::old_path::Path; +use std::io::Write; +use std::fs::hard_link; +use std::path::Path; #[path="../common/util.rs"] #[macro_use] @@ -28,7 +29,7 @@ pub fn uumain(args: Vec) -> i32 { getopts::optflag("V", "version", "output version information and exit"), ]; - let matches = match getopts::getopts(args.tail(), &opts) { + let matches = match getopts::getopts(&args[1..], &opts) { Ok(m) => m, Err(err) => panic!("{}", err), }; @@ -44,17 +45,17 @@ pub fn uumain(args: Vec) -> i32 { println!("Usage:"); println!(" {} [OPTIONS] FILE1 FILE2", NAME); println!(""); - print!("{}", getopts::usage("Create a link named FILE2 to FILE1.", opts.as_slice()).as_slice()); + print!("{}", getopts::usage("Create a link named FILE2 to FILE1.", &opts)); if matches.free.len() != 2 { return 1; } return 0; } - let old = Path::new(matches.free[0].as_slice()); - let new = Path::new(matches.free[1].as_slice()); + let old = Path::new(&matches.free[0]); + let new = Path::new(&matches.free[1]); - match link(&old, &new) { + match hard_link(old, new) { Ok(_) => 0, Err(err) => { show_error!("{}", err); diff --git a/src/sum/sum.rs b/src/sum/sum.rs index b0b898431..db49c605e 100644 --- a/src/sum/sum.rs +++ b/src/sum/sum.rs @@ -1,5 +1,5 @@ #![crate_name = "sum"] -#![feature(collections, core, old_io, old_path, rustc_private)] +#![feature(rustc_private)] /* * This file is part of the uutils coreutils package. @@ -13,8 +13,9 @@ extern crate getopts; extern crate libc; -use std::old_io::{File, IoResult, print}; -use std::old_io::stdio::{stdin_raw}; +use std::fs::File; +use std::io::{Read, Result, stdin, Write}; +use std::path::Path; #[path="../common/util.rs"] #[macro_use] @@ -23,7 +24,7 @@ mod util; static VERSION: &'static str = "1.0.0"; static NAME: &'static str = "sum"; -fn bsd_sum(mut reader: Box) -> (usize, u16) { +fn bsd_sum(mut reader: Box) -> (usize, u16) { let mut buf = [0; 1024]; let mut blocks_read = 0; let mut checksum: u16 = 0; @@ -43,7 +44,7 @@ fn bsd_sum(mut reader: Box) -> (usize, u16) { (blocks_read, checksum) } -fn sysv_sum(mut reader: Box) -> (usize, u16) { +fn sysv_sum(mut reader: Box) -> (usize, u16) { let mut buf = [0; 512]; let mut blocks_read = 0; let mut ret = 0; @@ -66,18 +67,18 @@ fn sysv_sum(mut reader: Box) -> (usize, u16) { (blocks_read, ret as u16) } -fn open(name: &str) -> IoResult> { +fn open(name: &str) -> Result> { match name { - "-" => Ok(Box::new(stdin_raw()) as Box), + "-" => Ok(Box::new(stdin()) as Box), _ => { let f = try!(File::open(&Path::new(name))); - Ok(Box::new(f) as Box) + Ok(Box::new(f) as Box) } } } pub fn uumain(args: Vec) -> i32 { - let program = args[0].as_slice(); + let program = &args[0]; let opts = [ getopts::optflag("r", "", "use the BSD compatible algorithm (default)"), getopts::optflag("s", "sysv", "use System V compatible algorithm"), @@ -85,7 +86,7 @@ pub fn uumain(args: Vec) -> i32 { getopts::optflag("v", "version", "print the version and exit"), ]; - let matches = match getopts::getopts(args.tail(), &opts) { + let matches = match getopts::getopts(&args[1..], &opts) { Ok(m) => m, Err(f) => crash!(1, "Invalid options\n{}", f) }; @@ -96,7 +97,7 @@ pub fn uumain(args: Vec) -> i32 { println!("Usage:"); println!(" {0} [OPTION]... [FILE]...", program); println!(""); - print(getopts::usage("checksum and count the blocks in a file", &opts).as_slice()); + print!("{}", getopts::usage("checksum and count the blocks in a file", &opts)); println!(""); println!("With no FILE, or when FILE is -, read standard input."); return 0; @@ -117,7 +118,7 @@ pub fn uumain(args: Vec) -> i32 { let print_names = sysv || files.len() > 1; for file in files.iter() { - let reader = match open(file.as_slice()) { + let reader = match open(file) { Ok(f) => f, _ => crash!(1, "unable to open file") };