Struct ZipStreamFileMetadata
pub struct ZipStreamFileMetadata(/* private field */);
Additional metadata for the file.
Implementations
impl ZipStreamFileMetadata
fn name(&self) -> &strGet 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_namemethod 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) -> PathBufRewrite the path, ignoring any path components with special meaning.
- Absolute paths are made relative
std::path::Component::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/../barasfoo/bar(instead ofbar). Because of this,ZipFile::enclosed_nameis 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/../baris fine,foo/../../baris 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) -> boolReturns whether the file is actually a directory
fn is_file(&self) -> boolReturns whether the file is a regular file
fn comment(&self) -> &strGet 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) -> TReturns 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) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses 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>