For archive listings, print '-' as the size for nodes other than regular files

This commit is contained in:
Nathan Fisher 2024-01-15 00:45:59 -05:00
parent d3ea6c0971
commit 01d5da2d89
1 changed files with 10 additions and 10 deletions

View File

@ -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),