Struct ZipFileEntryWithDataDescriptor

pub struct ZipFileEntryWithDataDescriptor<'a> { /* private fields */ }

A zip file Entry with a data descriptor (if present).

The method Self::data_descriptor can be use to retrieve it

Implementations

impl<'a> ZipFileEntryWithDataDescriptor<'a>

fn name_raw(&self) -> &[u8]

Get the name of the file, in the raw (internal) byte representation.

The encoding of this data is currently undefined.

fn name(&self) -> ZipResult<Cow<'_, str>>

Get the name of the file

Warnings

It is dangerous to use this name directly when extracting an archive. It may contain an absolute path (/etc/shadow), or break out of the current directory (../runtime). Carelessly writing to these paths allows an attacker to craft a ZIP archive that will overwrite critical files.

You can use the ZipFile::enclosed_name method to validate the name as a safe path.

fn mangled_name(&self) -> ZipResult<PathBuf>

Rewrite the path, ignoring any path components with special meaning.

  • Absolute paths are made relative
  • ParentDirs are ignored
  • Truncates the filename at a NULL byte

This is appropriate if you need to be able to extract something from any archive, but will easily misrepresent trivial paths like foo/../bar as foo/bar (instead of bar). Because of this, ZipFile::enclosed_name is the better option in most scenarios.

fn enclosed_name(&self) -> Option<PathBuf>

Ensure the file path is safe to use as a Path.

  • It can't contain NULL bytes
  • It can't resolve to a path outside the current directory

    foo/../bar is fine, foo/../../bar is not.

  • It can't be an absolute path

This will read well-formed ZIP files correctly, and is resistant to path-based exploits. It is recommended over ZipFile::mangled_name.

fn header_start(&self) -> u64

Get the starting offset of the zip header for this file

fn central_header_start(&self) -> u64

Get the starting offset of the zip header in the central directory for this file

fn version_made_by(&self) -> (u8, u8)

Get the version of the file

fn version_needed(&self) -> u16

PKZIP version needed to open this file (from APPNOTE 4.4.3.2).

fn comment(&self) -> &str

Get the comment of the file

fn system(&self) -> System

Get the system of the file

fn external_attributes(&self) -> u32

Get the external attributes of the file

fn flags(&self) -> ZipFileFlags

Get the flags of the file

fn compression(&self) -> CompressionMethod

Get the compression method used to store the file

fn encrypted(&self) -> bool

Get if the files is encrypted or not

fn compressed_size(&self) -> u64

Get the size of the file, in bytes, in the archive

fn size(&self) -> u64

Get the size of the file, in bytes, when uncompressed

fn last_modified(&self) -> Option<DateTime>

Get the time the file was last modified

fn is_dir(&self) -> bool

Returns whether the file is actually a directory

Returns whether the file is actually a symbolic link

fn is_file(&self) -> bool

Returns whether the file is a normal file (i.e. not a directory or symlink)

fn is_read_only(&self) -> bool

Returns whether the file is read-only. (On Unix, this means it's not readable by anyone.)

fn unix_mode(&self) -> Option<u32>

Get unix mode for the file

fn crc32(&self) -> u32

Get the CRC32 hash of the original file

fn data_descriptor(&self) -> &Option<ZipDataDescriptor>

Get the data descriptor

Trait Implementations

impl HasZipMetadata for ZipFileEntryWithDataDescriptor<'_>

fn get_metadata(&self) -> &ZipFileData

impl<'a> Debug for ZipFileEntryWithDataDescriptor<'a>

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Auto Trait Implementations

impl<'a> !Freeze for ZipFileEntryWithDataDescriptor<'a>

impl<'a> RefUnwindSafe for ZipFileEntryWithDataDescriptor<'a>

impl<'a> Send for ZipFileEntryWithDataDescriptor<'a>

impl<'a> Sync for ZipFileEntryWithDataDescriptor<'a>

impl<'a> Unpin for ZipFileEntryWithDataDescriptor<'a>

impl<'a> UnsafeUnpin for ZipFileEntryWithDataDescriptor<'a>

impl<'a> UnwindSafe for ZipFileEntryWithDataDescriptor<'a>

Blanket Implementations

impl<T> Any for ZipFileEntryWithDataDescriptor<'a> where T: 'static + ?Sized,

impl<T> Borrow<T> for ZipFileEntryWithDataDescriptor<'a> where T: ?Sized,

impl<T> BorrowMut<T> for ZipFileEntryWithDataDescriptor<'a> where T: ?Sized,

impl<T> From<T> for ZipFileEntryWithDataDescriptor<'a>

impl<T> Same for ZipFileEntryWithDataDescriptor<'a>

impl<T, U> Into<U> for ZipFileEntryWithDataDescriptor<'a> where U: From<T>,

impl<T, U> TryFrom<U> for ZipFileEntryWithDataDescriptor<'a> where U: Into<T>,

impl<T, U> TryInto<U> for ZipFileEntryWithDataDescriptor<'a> where U: TryFrom<T>,