diff --git a/src/directory.rs b/src/directory.rs index 2e2c412..bd3d9c3 100644 --- a/src/directory.rs +++ b/src/directory.rs @@ -21,11 +21,6 @@ impl Directory { self.size } - #[inline] - pub fn path(&self) -> &Path { - self.name.as_ref() - } - pub fn new< P: AsRef >(path: P, args: &Args) -> Result> { let path = path.as_ref(); // NOTE: I go back and forth on canonicalize()ing all the time. @@ -46,6 +41,7 @@ impl Directory { // symlink_metadata() is the same as metadata() but it doesn't // traverse symlinks, so that we can exclude them if necessary + // note: sizeof(Metadata) == 176 let meta = match path.symlink_metadata() { Ok(md) => md, Err(_) if args.persistant() => return Ok(None), @@ -66,7 +62,7 @@ impl Directory { return Ok(Some( Self { name, - size: meta.len(), + size: args.len(&meta), children: Vec::new() } )) @@ -85,7 +81,7 @@ impl Directory { (Err(e), false) => return Err(e), }; size += dir.size; - if args.tree() && args.should_print(dir.path()) { + if args.tree() && args.should_print(&dir.name) { // since size was increased, this just prevents // the directory from appearing in printing children.push(dir); @@ -144,7 +140,7 @@ impl Directory { pub fn tree(self, unit: Unit) -> String { // since self.size is definitionally the greatest value, the tab length // is just the length of self.len, plus two for a tab width - let tab_size = unit.convert(self.size).len() + 2; + let tab_size = unit.convert_with_units(self.size).len() + 2; self.vectorise(unit) .iter() .map(|e| e.stringify_tabbed(tab_size)) @@ -209,7 +205,7 @@ impl TreeEntry { } fn stringify_tabbed(&self, tab_size: usize) -> String { - let mut result = format!("{: