Skip to content

Commit

Permalink
Merge branch 'new-fs'
Browse files Browse the repository at this point in the history
  • Loading branch information
ogham committed May 3, 2015
2 parents eee49ec + 8eaa4c5 commit ffcc6fa
Show file tree
Hide file tree
Showing 11 changed files with 288 additions and 260 deletions.
133 changes: 89 additions & 44 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ name = "exa"

[dependencies]
ansi_term = "0.5.0"
bitflags = "0.1"
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"
bitflags = "0.1"
unicode-width = "*"
users = "0.4.0"

[features]
default = [ "git" ]
Expand Down
8 changes: 5 additions & 3 deletions src/column.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use std::iter::repeat;
use unicode::str::UnicodeStr;

use options::{SizeFormat, TimeType};

use ansi_term::Style;
use unicode_width::UnicodeWidthStr;


use options::{SizeFormat, TimeType};

#[derive(PartialEq, Debug, Copy, Clone)]
pub enum Column {
Expand Down Expand Up @@ -87,7 +89,7 @@ impl Cell {
pub fn paint(style: Style, string: &str) -> Cell {
Cell {
text: style.paint(string).to_string(),
length: string.width(false),
length: UnicodeWidthStr::width(string),
}
}
}
24 changes: 12 additions & 12 deletions src/dir.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
use std::old_io::{fs, IoResult};
use std::old_path::GenericPath;
use std::old_path::posix::Path;

use feature::Git;
use file::{File, GREY};

use std::io;
use std::fs;
use std::path::{Path, PathBuf};

/// A **Dir** provides a cached list of the file paths in a directory that's
/// being listed.
///
/// This object gets passed to the Files themselves, in order for them to
/// check the existence of surrounding files, then highlight themselves
/// accordingly. (See `File#get_source_files`)
pub struct Dir {
contents: Vec<Path>,
path: Path,
contents: Vec<PathBuf>,
path: PathBuf,
git: Option<Git>,
}

Expand All @@ -22,10 +22,10 @@ impl Dir {
/// Create a new Dir object filled with all the files in the directory
/// pointed to by the given path. Fails if the directory can't be read, or
/// isn't actually a directory.
pub fn readdir(path: &Path) -> IoResult<Dir> {
fs::readdir(path).map(|paths| Dir {
contents: paths,
path: path.clone(),
pub fn readdir(path: &Path) -> io::Result<Dir> {
fs::read_dir(path).map(|dir_obj| Dir {
contents: dir_obj.map(|entry| entry.unwrap().path()).collect(),
path: path.to_path_buf(),
git: Git::scan(path).ok(),
})
}
Expand All @@ -50,11 +50,11 @@ impl Dir {

/// Whether this directory contains a file with the given path.
pub fn contains(&self, path: &Path) -> bool {
self.contents.contains(path)
self.contents.iter().any(|ref p| p.as_path() == path)
}

/// Append a path onto the path specified by this directory.
pub fn join(&self, child: Path) -> Path {
pub fn join(&self, child: &Path) -> PathBuf {
self.path.join(child)
}

Expand Down
Loading

0 comments on commit ffcc6fa

Please sign in to comment.