Struct zip::unstable::stream::ZipStreamFileMetadata

source ·
pub struct ZipStreamFileMetadata(/* private fields */);
Expand description

Additional metadata for the file.

Implementations§

source§

impl ZipStreamFileMetadata

source

pub fn name(&self) -> &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.

source

pub 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.

source

pub fn mangled_name(&self) -> PathBuf

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

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.

source

pub 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.

source

pub fn is_dir(&self) -> bool

Returns whether the file is actually a directory

source

pub fn is_file(&self) -> bool

Returns whether the file is a regular file

source

pub fn comment(&self) -> &str

Get the comment of the file

source

pub fn data_start(&self) -> u64

Get the starting offset of the data of the compressed file

source

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

Get unix mode for the file

Trait Implementations§

source§

impl Debug for ZipStreamFileMetadata

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.