From 9c2858e447ac42296ca907747173d4585297fc64 Mon Sep 17 00:00:00 2001 From: Ben S Date: Sun, 22 Mar 2015 19:46:45 +0000 Subject: [PATCH] Upgrade to latest Rust - old_path::Path isn't imported by default anymore - range -> .. --- Cargo.lock | 16 ++++++++-------- src/dir.rs | 2 ++ src/file.rs | 10 ++++++++++ src/main.rs | 2 ++ src/output/details.rs | 2 +- src/xattr/xattr_darwin.rs | 16 +++++++++------- src/xattr/xattr_linux.rs | 12 +++++++----- 7 files changed, 39 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 25616da..9d34c5d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,13 +4,13 @@ version = "0.2.0" dependencies = [ "ansi_term 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "datetime 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "datetime 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "git2 0.2.5 (git+https://github.com/alexcrichton/git2-rs.git)", - "locale 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "locale 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "natord 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", "number_prefix 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "pad 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "pad 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "users 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -26,11 +26,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "datetime" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "locale 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "pad 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "locale 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "pad 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", "regex_macros 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -105,7 +105,7 @@ dependencies = [ [[package]] name = "locale" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -141,7 +141,7 @@ dependencies = [ [[package]] name = "pad" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] diff --git a/src/dir.rs b/src/dir.rs index f6b5445..9799ab3 100644 --- a/src/dir.rs +++ b/src/dir.rs @@ -1,4 +1,6 @@ use std::old_io::{fs, IoResult}; +use std::old_path::GenericPath; +use std::old_path::posix::Path; use file::{File, GREY}; #[cfg(feature="git")] use ansi_term::{ANSIString, ANSIStrings}; diff --git a/src/file.rs b/src/file.rs index 9d4f6da..46c344e 100644 --- a/src/file.rs +++ b/src/file.rs @@ -1,5 +1,13 @@ +// Yeah, we still have to use the old path and IO libraries, until they sprout +// the ability to inspect file types and stat times and other such things. +// +// There's a tracking issue for it: +// https://github.com/rust-lang/rfcs/issues/939 + use std::old_io::{fs, IoResult}; use std::old_io as io; +use std::old_path::GenericPath; +use std::old_path::posix::Path; use std::ascii::AsciiExt; use std::os::getcwd; @@ -494,6 +502,8 @@ pub mod test { pub use column::{Cell, Column}; pub use std::old_io as io; + pub use std::old_path::GenericPath; + pub use std::old_path::posix::Path; pub use output::details::UserLocale; pub use users::{User, Group}; diff --git a/src/main.rs b/src/main.rs index 8074557..247e62a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -19,6 +19,8 @@ extern crate git2; use std::env; use std::old_io::{fs, FileType}; +use std::old_path::GenericPath; +use std::old_path::posix::Path; use std::os::num_cpus; use std::sync::mpsc::{channel, sync_channel}; use std::thread; diff --git a/src/output/details.rs b/src/output/details.rs index dba0b0c..1414e61 100644 --- a/src/output/details.rs +++ b/src/output/details.rs @@ -170,7 +170,7 @@ impl Table { // Work out the list of column widths by finding the longest cell for // each column, then formatting each cell in that column to be the // width of that one. - let column_widths: Vec = range(0, self.columns.len()) + let column_widths: Vec = (0 .. self.columns.len()) .map(|n| self.rows.iter().map(|row| row.cells[n].length).max().unwrap_or(0)) .collect(); diff --git a/src/xattr/xattr_darwin.rs b/src/xattr/xattr_darwin.rs index 034b8dc..cc51107 100644 --- a/src/xattr/xattr_darwin.rs +++ b/src/xattr/xattr_darwin.rs @@ -5,12 +5,14 @@ use std::ffi::CString; use std::ptr; use std::mem; use std::old_io as io; +use std::old_path::GenericPath; +use std::old_path::posix::Path; use self::libc::{c_int, size_t, ssize_t, c_char, c_void, uint32_t}; /// Don't follow symbolic links -const XATTR_NOFOLLOW: c_int = 0x0001; +const XATTR_NOFOLLOW: c_int = 0x0001; /// Expose HFS Compression extended attributes -const XATTR_SHOWCOMPRESSION: c_int = 0x0020; +const XATTR_SHOWCOMPRESSION: c_int = 0x0020; extern "C" { fn listxattr(path: *const c_char, namebuf: *mut c_char, @@ -45,7 +47,7 @@ impl Attribute { c_flags |= flag as c_int } let c_path = try!(CString::new(path.as_vec())); - let bufsize = unsafe { + let bufsize = unsafe { listxattr(c_path.as_ptr(), ptr::null_mut(), 0, c_flags) }; if bufsize > 0 { @@ -73,11 +75,11 @@ impl Attribute { ) }; if size > 0 { - names.push(Attribute { + names.push(Attribute { name: unsafe { // buf is guaranteed to contain valid utf8 strings // see man listxattr - mem::transmute::<&[u8], &str>(&buf[start..end]).to_string() + mem::transmute::<&[u8], &str>(&buf[start..end]).to_string() }, size: size as usize }); @@ -100,7 +102,7 @@ impl Attribute { }) } } - + /// Getter for name pub fn name(&self) -> &str { &self.name @@ -125,4 +127,4 @@ pub fn llist(path: &Path) -> io::IoResult> { /// Returns true if the extended attribute feature is implemented on this platform. #[inline(always)] -pub fn feature_implemented() -> bool { true } \ No newline at end of file +pub fn feature_implemented() -> bool { true } diff --git a/src/xattr/xattr_linux.rs b/src/xattr/xattr_linux.rs index 7f83969..47c368e 100644 --- a/src/xattr/xattr_linux.rs +++ b/src/xattr/xattr_linux.rs @@ -4,15 +4,17 @@ extern crate libc; use std::ffi::CString; use std::ptr; use std::old_io as io; +use std::old_path::GenericPath; +use std::old_path::posix::Path; use self::libc::{size_t, ssize_t, c_char, c_void}; extern "C" { fn listxattr(path: *const c_char, list: *mut c_char, size: size_t) -> ssize_t; fn llistxattr(path: *const c_char, list: *mut c_char, size: size_t) -> ssize_t; - fn getxattr(path: *const c_char, name: *const c_char, + fn getxattr(path: *const c_char, name: *const c_char, value: *mut c_void, size: size_t ) -> ssize_t; - fn lgetxattr(path: *const c_char, name: *const c_char, + fn lgetxattr(path: *const c_char, name: *const c_char, value: *mut c_void, size: size_t ) -> ssize_t; } @@ -68,7 +70,7 @@ impl Attribute { ) }; if size > 0 { - names.push(Attribute { + names.push(Attribute { name: String::from_utf8_lossy(&buf[start..end]).into_owned(), size: size as usize }); @@ -91,7 +93,7 @@ impl Attribute { }) } } - + /// Getter for name pub fn name(&self) -> &str { &self.name @@ -116,4 +118,4 @@ pub fn llist(path: &Path) -> io::IoResult> { /// Returns true if the extended attribute feature is implemented on this platform. #[inline(always)] -pub fn feature_implemented() -> bool { true } \ No newline at end of file +pub fn feature_implemented() -> bool { true }