From ba8165c607481605acf011d8bb0a437990af889a Mon Sep 17 00:00:00 2001 From: Christian Ebner Date: Tue, 22 Oct 2019 15:07:50 +0200 Subject: [PATCH] pxar: encoder: add encode_pxar_exclude_cli() function. This provides the functionality needed to encode MatchPatterns passed on the cli in the root directory. Signed-off-by: Christian Ebner --- src/pxar/encoder.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/pxar/encoder.rs b/src/pxar/encoder.rs index 8abde25d..d427e7a3 100644 --- a/src/pxar/encoder.rs +++ b/src/pxar/encoder.rs @@ -1171,6 +1171,30 @@ impl<'a, W: Write, C: BackupCatalogWriter> Encoder<'a, W, C> { Ok(()) } + /// Encodes the excude match patterns passed via cli as file in the archive. + fn encode_pxar_exclude_cli( + &mut self, + uid: u32, + gid: u32, + mtime: u64, + content: &[u8], + ) -> Result<(), Error> { + let entry = PxarEntry { + mode: (libc::S_IFREG | 0o600) as u64, + flags: 0, + uid, + gid, + mtime, + }; + self.write_entry(entry)?; + let size = content.len(); + self.write_header(PXAR_PAYLOAD, size as u64)?; + self.writer.write_all(content)?; + self.writer_pos += size; + + Ok(()) + } + // the report_XXX method may raise and error - depending on encoder configuration fn report_vanished_file(&self, path: &Path) -> Result<(), Error> {