summaryrefslogtreecommitdiffstats
path: root/vendor/tar/src/archive.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/tar/src/archive.rs')
-rw-r--r--vendor/tar/src/archive.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/vendor/tar/src/archive.rs b/vendor/tar/src/archive.rs
index 1bed51249..c7a9d9803 100644
--- a/vendor/tar/src/archive.rs
+++ b/vendor/tar/src/archive.rs
@@ -22,8 +22,10 @@ pub struct Archive<R: ?Sized + Read> {
pub struct ArchiveInner<R: ?Sized> {
pos: Cell<u64>,
+ mask: u32,
unpack_xattrs: bool,
preserve_permissions: bool,
+ preserve_ownerships: bool,
preserve_mtime: bool,
overwrite: bool,
ignore_zeros: bool,
@@ -52,8 +54,10 @@ impl<R: Read> Archive<R> {
pub fn new(obj: R) -> Archive<R> {
Archive {
inner: ArchiveInner {
+ mask: u32::MIN,
unpack_xattrs: false,
preserve_permissions: false,
+ preserve_ownerships: false,
preserve_mtime: true,
overwrite: true,
ignore_zeros: false,
@@ -106,6 +110,20 @@ impl<R: Read> Archive<R> {
me._unpack(dst.as_ref())
}
+ /// Set the mask of the permission bits when unpacking this entry.
+ ///
+ /// The mask will be inverted when applying against a mode, similar to how
+ /// `umask` works on Unix. In logical notation it looks like:
+ ///
+ /// ```text
+ /// new_mode = old_mode & (~mask)
+ /// ```
+ ///
+ /// The mask is 0 by default and is currently only implemented on Unix.
+ pub fn set_mask(&mut self, mask: u32) {
+ self.inner.mask = mask;
+ }
+
/// Indicate whether extended file attributes (xattrs on Unix) are preserved
/// when unpacking this archive.
///
@@ -126,6 +144,15 @@ impl<R: Read> Archive<R> {
self.inner.preserve_permissions = preserve;
}
+ /// Indicate whether numeric ownership ids (like uid and gid on Unix)
+ /// are preserved when unpacking this entry.
+ ///
+ /// This flag is disabled by default and is currently only implemented on
+ /// Unix.
+ pub fn set_preserve_ownerships(&mut self, preserve: bool) {
+ self.inner.preserve_ownerships = preserve;
+ }
+
/// Indicate whether files and symlinks should be overwritten on extraction.
pub fn set_overwrite(&mut self, overwrite: bool) {
self.inner.overwrite = overwrite;
@@ -304,10 +331,12 @@ impl<'a> EntriesFields<'a> {
long_pathname: None,
long_linkname: None,
pax_extensions: None,
+ mask: self.archive.inner.mask,
unpack_xattrs: self.archive.inner.unpack_xattrs,
preserve_permissions: self.archive.inner.preserve_permissions,
preserve_mtime: self.archive.inner.preserve_mtime,
overwrite: self.archive.inner.overwrite,
+ preserve_ownerships: self.archive.inner.preserve_ownerships,
};
// Store where the next entry is, rounding up by 512 bytes (the size of