From 132cb0d0db101332883c0f9e7f275c16d6dd0c07 Mon Sep 17 00:00:00 2001 From: Christian Ebner Date: Thu, 5 Sep 2019 13:17:40 +0200 Subject: [PATCH] src/pxar/decoder.rs: Add comment for unsolved issue and refactor if statement. Signed-off-by: Christian Ebner --- src/pxar/decoder.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/pxar/decoder.rs b/src/pxar/decoder.rs index 12776d66..7af89fa2 100644 --- a/src/pxar/decoder.rs +++ b/src/pxar/decoder.rs @@ -98,6 +98,10 @@ impl Result<(), Error>> Decoder { let head: PxarHeader = self.inner.read_item()?; if head.htype == PXAR_FORMAT_HARDLINK { let (_, offset) = self.inner.read_hardlink(head.size)?; + // TODO: Howto find correct end offset for hardlink target? + // This is a bit tricky since we cannot find correct end in an efficient + // way, on the other hand it doesn't really matter (for now) since target + // is never a directory and end is not used in such cases. return self.read_directory_entry(start - offset, end); } check_ca_header::(&head, PXAR_ENTRY)?; @@ -231,14 +235,10 @@ impl Result<(), Error>> Decoder { writeln!(output, "{:?}", prefix)?; - if ifmt == libc::S_IFDIR { - self.print_filenames(output, prefix, item)?; - } else if ifmt == libc::S_IFREG { - } else if ifmt == libc::S_IFLNK { - } else if ifmt == libc::S_IFBLK { - } else if ifmt == libc::S_IFCHR { - } else { - bail!("unknown item mode/type for {:?}", prefix); + match ifmt { + libc::S_IFDIR => self.print_filenames(output, prefix, item)?, + libc::S_IFREG | libc::S_IFLNK | libc::S_IFBLK | libc::S_IFCHR => {} + _ => bail!("unknown item mode/type for {:?}", prefix), } prefix.pop();