diff --git a/Cargo.lock b/Cargo.lock index 2d11e0d..bcdb662 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,21 +2,22 @@ name = "exa" version = "0.2.0" dependencies = [ - "ansi_term 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ansi_term 0.5.1 (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.5 (registry+https://github.com/rust-lang/crates.io-index)", - "getopts 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "git2 0.2.6 (git+https://github.com/alexcrichton/git2-rs.git)", + "getopts 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", + "git2 0.2.8 (git+https://github.com/alexcrichton/git2-rs.git)", "locale 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "natord 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 0.1.0 (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.3 (registry+https://github.com/rust-lang/crates.io-index)", - "users 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "users 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "ansi_term" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -31,49 +32,49 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "locale 0.1.6 (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.21 (registry+https://github.com/rust-lang/crates.io-index)", - "regex_macros 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "regex_macros 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "gcc" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "getopts" -version = "0.2.5" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "log 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "git2" -version = "0.2.6" -source = "git+https://github.com/alexcrichton/git2-rs.git#e79e709310196873a4e6a8e5893295ea9d0fab56" +version = "0.2.8" +source = "git+https://github.com/alexcrichton/git2-rs.git#1f2cb994360df26a7a84c8ed17dd14929ba7dcd7" dependencies = [ "bitflags 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libgit2-sys 0.2.7 (git+https://github.com/alexcrichton/git2-rs.git)", - "url 0.2.28 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "libgit2-sys 0.2.10 (git+https://github.com/alexcrichton/git2-rs.git)", + "url 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libc" -version = "0.1.3" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libgit2-sys" -version = "0.2.7" -source = "git+https://github.com/alexcrichton/git2-rs.git#e79e709310196873a4e6a8e5893295ea9d0fab56" +version = "0.2.10" +source = "git+https://github.com/alexcrichton/git2-rs.git#1f2cb994360df26a7a84c8ed17dd14929ba7dcd7" dependencies = [ - "libc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libssh2-sys 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "libssh2-sys 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "libz-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -86,13 +87,13 @@ dependencies = [ [[package]] name = "libssh2-sys" -version = "0.1.15" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "libz-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -100,7 +101,7 @@ name = "libz-sys" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "pkg-config 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -110,8 +111,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "log" -version = "0.2.5" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "matches" @@ -123,6 +127,15 @@ name = "natord" version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "num_cpus" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "gcc 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "number_prefix" version = "0.2.3" @@ -130,13 +143,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "openssl-sys" -version = "0.5.2" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "gcc 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "gcc 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "libressl-pnacl-sys 2.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -146,7 +159,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "pkg-config" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -156,36 +169,36 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "regex" -version = "0.1.21" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "regex_macros" -version = "0.1.13" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "regex 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rustc-serialize" -version = "0.3.7" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "url" -version = "0.2.28" +version = "0.2.29" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "users" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/Cargo.toml b/Cargo.toml index 17b1bc6..628699f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,7 @@ datetime = "0.1.3" getopts = "0.2.1" locale = "0.1.2" natord = "1.0.7" +num_cpus = "*" number_prefix = "0.2.3" pad = "0.1.1" users = "0.3.1" diff --git a/src/column.rs b/src/column.rs index 51ea239..677a917 100644 --- a/src/column.rs +++ b/src/column.rs @@ -21,7 +21,7 @@ pub enum Column { /// Each column can pick its own **Alignment**. Usually, numbers are /// right-aligned, and text is left-aligned. -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum Alignment { Left, Right, } diff --git a/src/feature/xattr_darwin.rs b/src/feature/xattr_darwin.rs index 4d4021a..d3f3428 100644 --- a/src/feature/xattr_darwin.rs +++ b/src/feature/xattr_darwin.rs @@ -23,7 +23,7 @@ extern "C" { } /// Attributes which can be passed to `Attribute::list_with_flags` -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum ListFlags { /// Don't follow symbolic links NoFollow = XATTR_NOFOLLOW as isize, diff --git a/src/feature/xattr_linux.rs b/src/feature/xattr_linux.rs index 0aef938..06496ea 100644 --- a/src/feature/xattr_linux.rs +++ b/src/feature/xattr_linux.rs @@ -20,7 +20,7 @@ extern "C" { } /// Attributes which can be passed to `Attribute::list_with_flags` -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum FollowSymlinks { Yes, No diff --git a/src/file.rs b/src/file.rs index a226f56..d1f1c2f 100644 --- a/src/file.rs +++ b/src/file.rs @@ -9,7 +9,7 @@ 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; +use std::env::current_dir; use unicode::str::UnicodeStr; use ansi_term::{ANSIString, ANSIStrings, Colour, Style}; @@ -458,10 +458,19 @@ impl<'a> File<'a> { } fn git_status(&self) -> Cell { + use std::os::unix::ffi::OsStrExt; + use std::ffi::AsOsStr; + let status = match self.dir { - Some(d) => d.git_status(&getcwd().unwrap_or(Path::new(".")).join(&self.path), - self.is_directory()), None => GREY.paint("--").to_string(), + Some(d) => { + let cwd = match current_dir() { + Err(_) => Path::new(".").join(&self.path), + Ok(dir) => Path::new(dir.as_os_str().as_bytes()).join(&self.path), + }; + + d.git_status(&cwd, self.is_directory()) + }, }; Cell { text: status, length: 2 } diff --git a/src/filetype.rs b/src/filetype.rs index 074b292..fa16b53 100644 --- a/src/filetype.rs +++ b/src/filetype.rs @@ -7,7 +7,7 @@ use ansi_term::Style; use ansi_term::Style::Plain; use ansi_term::Colour::{Red, Green, Yellow, Blue, Cyan, Fixed}; -#[derive(PartialEq, Debug, Copy)] +#[derive(PartialEq, Debug)] pub enum FileType { Normal, Directory, Executable, Immediate, Compiled, Symlink, Special, Image, Video, Music, Lossless, Compressed, Document, Temp, Crypto, diff --git a/src/main.rs b/src/main.rs index 263d5c1..808e9db 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,6 +10,7 @@ extern crate datetime; extern crate getopts; extern crate locale; extern crate natord; +extern crate num_cpus; extern crate number_prefix; extern crate pad; extern crate unicode; @@ -22,7 +23,6 @@ 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; @@ -68,7 +68,7 @@ impl<'a> Exa<'a> { let total_files = files.len(); // Denotes the maxinum number of concurrent threads - let (thread_capacity_tx, thread_capacity_rs) = sync_channel(8 * num_cpus()); + let (thread_capacity_tx, thread_capacity_rs) = sync_channel(8 * num_cpus::get()); // Communication between consumer thread and producer threads enum StatResult<'a> { diff --git a/src/options.rs b/src/options.rs index 5a132cf..6ca987a 100644 --- a/src/options.rs +++ b/src/options.rs @@ -19,14 +19,14 @@ use self::Misfire::*; /// The *Options* struct represents a parsed version of the user's /// command-line options. -#[derive(PartialEq, Debug, Copy)] +#[derive(PartialEq, Debug, Copy, Clone)] pub struct Options { pub dir_action: DirAction, pub filter: FileFilter, pub view: View, } -#[derive(PartialEq, Debug, Copy)] +#[derive(PartialEq, Debug, Copy, Clone)] pub struct FileFilter { list_dirs_first: bool, reverse: bool, @@ -34,7 +34,7 @@ pub struct FileFilter { sort_field: SortField, } -#[derive(PartialEq, Debug, Copy)] +#[derive(PartialEq, Debug, Copy, Clone)] pub enum View { Details(Details), Lines, @@ -160,7 +160,7 @@ impl FileFilter { } /// User-supplied field to sort by. -#[derive(PartialEq, Debug, Copy)] +#[derive(PartialEq, Debug, Copy, Clone)] pub enum SortField { Unsorted, Name, Extension, Size, FileInode, ModifiedDate, AccessedDate, CreatedDate, @@ -362,7 +362,7 @@ impl TimeType { } } -#[derive(PartialEq, Debug, Copy)] +#[derive(PartialEq, Debug, Copy, Clone)] pub struct TimeTypes { accessed: bool, modified: bool, @@ -413,7 +413,7 @@ impl TimeTypes { } /// What to do when encountering a directory? -#[derive(PartialEq, Debug, Copy)] +#[derive(PartialEq, Debug, Copy, Clone)] pub enum DirAction { AsFile, List, @@ -458,7 +458,7 @@ impl DirAction { } } -#[derive(PartialEq, Debug, Copy)] +#[derive(PartialEq, Debug, Copy, Clone)] pub struct RecurseOptions { pub tree: bool, pub max_depth: Option, @@ -492,7 +492,7 @@ impl RecurseOptions { } } -#[derive(PartialEq, Copy, Debug)] +#[derive(PartialEq, Copy, Clone, Debug)] pub struct Columns { size_format: SizeFormat, time_types: TimeTypes, diff --git a/src/output/details.rs b/src/output/details.rs index 8e73e69..d512432 100644 --- a/src/output/details.rs +++ b/src/output/details.rs @@ -19,7 +19,7 @@ use ansi_term::Style::Plain; /// /// Almost all the heavy lifting is done in a Table object, which handles the /// columns for each row. -#[derive(PartialEq, Debug, Copy)] +#[derive(PartialEq, Debug, Copy, Clone)] pub struct Details { /// A Columns object that says which columns should be included in the diff --git a/src/output/grid.rs b/src/output/grid.rs index 0bd4cf7..abdc638 100644 --- a/src/output/grid.rs +++ b/src/output/grid.rs @@ -5,7 +5,7 @@ use super::lines::lines_view; use std::cmp::max; use std::iter::{AdditiveIterator, repeat}; -#[derive(PartialEq, Debug, Copy)] +#[derive(PartialEq, Debug, Copy, Clone)] pub struct Grid { pub across: bool, pub console_width: usize,