summaryrefslogtreecommitdiffstats
path: root/src/output/grid_details.rs
diff options
context:
space:
mode:
authorBen S <ogham@bsago.me>2015-08-26 12:00:31 +0100
committerBen S <ogham@bsago.me>2015-08-26 12:00:31 +0100
commit5e1ff9cdcd1c6792b6dd3374ab6dc50e0bf5f669 (patch)
treebef1b3e576685235e1cdd3e6082164ca1c78362c /src/output/grid_details.rs
parent31dec1d1bab6821fef8591f755a37d779c3a2d01 (diff)
Restore xattrs to their long view column
Had to thread the value in at display-time to get it to only query the attributes once! This isn't the nicest way to do it, but this *is* a bit of an edge-case (it's the only thing where a column depends on something that gets calculated later)
Diffstat (limited to 'src/output/grid_details.rs')
-rw-r--r--src/output/grid_details.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/output/grid_details.rs b/src/output/grid_details.rs
index 5a5804d..bca3c8b 100644
--- a/src/output/grid_details.rs
+++ b/src/output/grid_details.rs
@@ -5,6 +5,7 @@ use term_grid as grid;
use column::{Column, Cell};
use dir::Dir;
+use feature::xattr::FileAttributes;
use file::File;
use output::details::{Details, Table};
use output::grid::Grid;
@@ -15,6 +16,13 @@ pub struct GridDetails {
pub details: Details,
}
+fn file_has_xattrs(file: &File) -> bool {
+ match file.path.attributes() {
+ Ok(attrs) => !attrs.is_empty(),
+ Err(_) => false,
+ }
+}
+
impl GridDetails {
pub fn view(&self, dir: Option<&Dir>, files: &[File]) {
let columns_for_dir = match self.details.columns {
@@ -23,7 +31,7 @@ impl GridDetails {
};
let mut first_table = Table::with_options(self.details.colours, columns_for_dir.clone());
- let cells: Vec<_> = files.iter().map(|file| first_table.cells_for_file(file)).collect();
+ let cells: Vec<_> = files.iter().map(|file| first_table.cells_for_file(file, file_has_xattrs(file))).collect();
let mut last_working_table = self.make_grid(1, &*columns_for_dir, files, cells.clone());