diff options
author | Ben S <ogham@bsago.me> | 2015-02-26 14:05:26 +0000 |
---|---|---|
committer | Ben S <ogham@bsago.me> | 2015-02-26 14:05:26 +0000 |
commit | ff1f6d0087f6475474c77031ded85be9e35cebfa (patch) | |
tree | a352b1ffae3e0ec2898ac5f2e539e35001a5eddd /src/file.rs | |
parent | 982352009fffa5af3a469108772c63d12754bc44 (diff) |
Add --group-directories-first option
Closes #27.
Diffstat (limited to 'src/file.rs')
-rw-r--r-- | src/file.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/file.rs b/src/file.rs index 3dc50df..efc4797 100644 --- a/src/file.rs +++ b/src/file.rs @@ -91,6 +91,11 @@ impl<'a> File<'a> { name.ends_with("~") || (name.starts_with("#") && name.ends_with("#")) } + /// Whether this file is a directory or not. + pub fn is_directory(&self) -> bool { + self.stat.kind == io::FileType::Directory + } + /// Get the data for a column, formatted as a coloured string. pub fn display<U: Users>(&self, column: &Column, users_cache: &mut U, locale: &UserLocale) -> Cell { match *column { @@ -300,7 +305,7 @@ impl<'a> File<'a> { /// any information from it, so by emitting "-" instead, the table is less /// cluttered with numbers. fn file_size(&self, size_format: SizeFormat, locale: &locale::Numeric) -> Cell { - if self.stat.kind == io::FileType::Directory { + if self.is_directory() { Cell { text: GREY.paint("-").to_string(), length: 1 } } else { @@ -363,7 +368,7 @@ impl<'a> File<'a> { /// Marker indicating that the file contains extended attributes /// - /// Returns “@” or “ ” depending on wheter the file contains an extented + /// Returns “@” or “ ” depending on wheter the file contains an extented /// attribute or not. Also returns “ ” in case the attributes cannot be read /// for some reason. fn attribute_marker(&self) -> ANSIString { @@ -447,7 +452,7 @@ impl<'a> File<'a> { fn git_status(&self) -> Cell { let status = match self.dir { Some(d) => d.git_status(¤t_dir().unwrap_or(Path::new(".")).join(&self.path), - self.stat.kind == io::FileType::Directory), + self.is_directory()), None => GREY.paint("--").to_string(), }; |