Upgrade to latest Rust

- old_path::Path isn't imported by default anymore
- range -> ..
This commit is contained in:
Ben S 2015-03-22 19:46:45 +00:00
parent 1986c504ba
commit 9c2858e447
7 changed files with 39 additions and 21 deletions

16
Cargo.lock generated
View File

@ -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]]

View File

@ -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};

View File

@ -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};

View File

@ -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;

View File

@ -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<usize> = range(0, self.columns.len())
let column_widths: Vec<usize> = (0 .. self.columns.len())
.map(|n| self.rows.iter().map(|row| row.cells[n].length).max().unwrap_or(0))
.collect();

View File

@ -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<Vec<Attribute>> {
/// Returns true if the extended attribute feature is implemented on this platform.
#[inline(always)]
pub fn feature_implemented() -> bool { true }
pub fn feature_implemented() -> bool { true }

View File

@ -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<Vec<Attribute>> {
/// Returns true if the extended attribute feature is implemented on this platform.
#[inline(always)]
pub fn feature_implemented() -> bool { true }
pub fn feature_implemented() -> bool { true }