Struct ZipStreamFileMetadata

pub struct ZipStreamFileMetadata(/* private field */);

Additional metadata for the file.

Implementations

impl ZipStreamFileMetadata

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.

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

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 is_dir(&self) -> bool

Returns whether the file is actually a directory

fn is_file(&self) -> bool

Returns whether the file is a regular file

fn comment(&self) -> &str

Get the comment of the file

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

Get unix mode for the file

Trait Implementations

impl Debug for ZipStreamFileMetadata

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

Auto Trait Implementations

impl !Freeze for ZipStreamFileMetadata

impl RefUnwindSafe for ZipStreamFileMetadata

impl Send for ZipStreamFileMetadata

impl Sync for ZipStreamFileMetadata

impl Unpin for ZipStreamFileMetadata

impl UnsafeUnpin for ZipStreamFileMetadata

impl UnwindSafe for ZipStreamFileMetadata

Blanket Implementations

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

fn type_id(&self) -> TypeId

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

fn borrow(&self) -> &T

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

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

impl<T> From<T> for ZipStreamFileMetadata

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> Same for ZipStreamFileMetadata

type Output = T;

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

fn into(self) -> U

Calls U::from(self).

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

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

type Error = never;
fn try_from(value: U) -> Result<T, never>

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

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