diff options
author | Benjamin Sago <ogham@bsago.me> | 2015-04-04 00:14:49 +0200 |
---|---|---|
committer | Benjamin Sago <ogham@bsago.me> | 2015-04-04 00:14:56 +0200 |
commit | f88556814566dbc1c1cde626cb8d5933c6db5b92 (patch) | |
tree | 50ed3fc800e79c0945e0323836d1dcabe3b8658c /src/file.rs | |
parent | 8d066994e75f1c9f30ae6a792e0a399763d74779 (diff) |
Upgrade to latest Rust
Still missing a few Beta features, but it compiles!
- Copy requires Clone
- current_dir returns a Path now
- num_cpus moved to a crate
Diffstat (limited to 'src/file.rs')
-rw-r--r-- | src/file.rs | 15 |
1 files changed, 12 insertions, 3 deletions
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 } |