From 01d5da2d89e307aed2309abf8bf065a3883dd158 Mon Sep 17 00:00:00 2001 From: Nathan Fisher Date: Mon, 15 Jan 2024 00:45:59 -0500 Subject: [PATCH] For archive listings, print '-' as the size for nodes other than regular files --- src/listing.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/listing.rs b/src/listing.rs index f998481..779fdb0 100644 --- a/src/listing.rs +++ b/src/listing.rs @@ -147,7 +147,7 @@ impl fmt::Display for Listing { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!( f, - "{}{}{}{}{}{}{}{}{}{} {:>4}:{:<4} {:>10} ", + "{}{}{}{}{}{}{}{}{}{} {:>4}:{:<4} ", match self.kind { Kind::Normal(_) => "-", Kind::HardLink(_) => "L", @@ -199,11 +199,11 @@ impl fmt::Display for Listing { }, self.uid, self.gid, - match self.kind { - Kind::Normal(s) => s, - _ => 0, - }, )?; + match self.kind { + Kind::Normal(s) => write!(f, "{s:>10} "), + _ => write!(f, "{:>10}", "-"), + }?; match NaiveDateTime::from_timestamp_opt(self.mtime as i64, 0) { Some(dt) => write!(f, "{dt} ")?, _ => write!(f, "{:>19} ", self.mtime)?, @@ -266,7 +266,7 @@ impl Listing { #[cfg(feature = "color")] pub fn print_color(&self) -> Result<(), Error> { print!( - "{}{}{}{}{}{}{}{}{}{} {:>4}:{:<4} {:>10} ", + "{}{}{}{}{}{}{}{}{}{} {:>4}:{:<4} ", match self.kind { Kind::Normal(_) => "-", Kind::HardLink(_) => "L", @@ -318,11 +318,11 @@ impl Listing { }, self.uid, self.gid, - match self.kind { - Kind::Normal(s) => s, - _ => 0, - }, ); + match self.kind { + Kind::Normal(s) => write!(f, "{s:>10} "), + _ => write!(f, "{:>10}", "-"), + }?; match NaiveDateTime::from_timestamp_opt(self.mtime as i64, 0) { Some(dt) => print!("{dt} "), _ => print!("{:>19} ", self.mtime),