Struct zip::read::ZipFile [−][src]
A struct for reading a zip file
Implementations
impl<'a> ZipFile<'a>
[src]
Methods for retrieving information on zip files
pub fn version_made_by(&self) -> (u8, u8)
[src]
Get the version of the file
pub fn name(&self) -> &str
[src]
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.
pub fn name_raw(&self) -> &[u8]
[src]
Get the name of the file, in the raw (internal) byte representation.
The encoding of this data is currently undefined.
pub fn sanitized_name(&self) -> PathBuf
[src]
by stripping ..
s from the path, the meaning of paths can change.
mangled_name
can be used if this behaviour is desirable
Get the name of the file in a sanitized form. It truncates the name to the first NULL byte, removes a leading '/' and removes '..' parts.
pub fn mangled_name(&self) -> PathBuf
[src]
Rewrite the path, ignoring any path components with special meaning.
- Absolute paths are made relative
ParentDir
s 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.
pub fn enclosed_name(&self) -> Option<&Path>
[src]
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
.
pub fn comment(&self) -> &str
[src]
Get the comment of the file
pub fn compression(&self) -> CompressionMethod
[src]
Get the compression method used to store the file
pub fn compressed_size(&self) -> u64
[src]
Get the size of the file in the archive
pub fn size(&self) -> u64
[src]
Get the size of the file when uncompressed
pub fn last_modified(&self) -> DateTime
[src]
Get the time the file was last modified
pub fn is_dir(&self) -> bool
[src]
Returns whether the file is actually a directory
pub fn is_file(&self) -> bool
[src]
Returns whether the file is a regular file
pub fn unix_mode(&self) -> Option<u32>
[src]
Get unix mode for the file
pub fn crc32(&self) -> u32
[src]
Get the CRC32 hash of the original file
pub fn data_start(&self) -> u64
[src]
Get the starting offset of the data of the compressed file
pub fn header_start(&self) -> u64
[src]
Get the starting offset of the zip header for this file
pub fn central_header_start(&self) -> u64
[src]
Get the starting offset of the zip header in the central directory for this file
Trait Implementations
impl<'a> Drop for ZipFile<'a>
[src]
impl<'a> Read for ZipFile<'a>
[src]
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
[src]
pub fn read_vectored(
&mut self,
bufs: &mut [IoSliceMut<'_>]
) -> Result<usize, Error>
1.36.0[src]
&mut self,
bufs: &mut [IoSliceMut<'_>]
) -> Result<usize, Error>
pub fn is_read_vectored(&self) -> bool
[src]
pub unsafe fn initializer(&self) -> Initializer
[src]
pub fn read_to_end(&mut self, buf: &mut Vec<u8, Global>) -> Result<usize, Error>
1.0.0[src]
pub fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
1.0.0[src]
pub fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
1.6.0[src]
pub fn by_ref(&mut self) -> &mut Self
1.0.0[src]
pub fn bytes(self) -> Bytes<Self>
1.0.0[src]
pub fn chain<R>(self, next: R) -> Chain<Self, R> where
R: Read,
1.0.0[src]
R: Read,
pub fn take(self, limit: u64) -> Take<Self>
1.0.0[src]
Auto Trait Implementations
impl<'a> !RefUnwindSafe for ZipFile<'a>
[src]
impl<'a> !Send for ZipFile<'a>
[src]
impl<'a> !Sync for ZipFile<'a>
[src]
impl<'a> Unpin for ZipFile<'a>
[src]
impl<'a> !UnwindSafe for ZipFile<'a>
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<R> ReadBytesExt for R where
R: Read + ?Sized,
[src]
R: Read + ?Sized,
pub fn read_u8(&mut self) -> Result<u8, Error>
[src]
pub fn read_i8(&mut self) -> Result<i8, Error>
[src]
pub fn read_u16<T>(&mut self) -> Result<u16, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
pub fn read_i16<T>(&mut self) -> Result<i16, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
pub fn read_u24<T>(&mut self) -> Result<u32, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
pub fn read_i24<T>(&mut self) -> Result<i32, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
pub fn read_u32<T>(&mut self) -> Result<u32, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
pub fn read_i32<T>(&mut self) -> Result<i32, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
pub fn read_u48<T>(&mut self) -> Result<u64, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
pub fn read_i48<T>(&mut self) -> Result<i64, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
pub fn read_u64<T>(&mut self) -> Result<u64, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
pub fn read_i64<T>(&mut self) -> Result<i64, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
pub fn read_u128<T>(&mut self) -> Result<u128, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
pub fn read_i128<T>(&mut self) -> Result<i128, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
pub fn read_uint<T>(&mut self, nbytes: usize) -> Result<u64, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
pub fn read_int<T>(&mut self, nbytes: usize) -> Result<i64, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
pub fn read_uint128<T>(&mut self, nbytes: usize) -> Result<u128, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
pub fn read_int128<T>(&mut self, nbytes: usize) -> Result<i128, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
pub fn read_f32<T>(&mut self) -> Result<f32, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
pub fn read_f64<T>(&mut self) -> Result<f64, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
pub fn read_u16_into<T>(&mut self, dst: &mut [u16]) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
pub fn read_u32_into<T>(&mut self, dst: &mut [u32]) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
pub fn read_u64_into<T>(&mut self, dst: &mut [u64]) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
pub fn read_u128_into<T>(&mut self, dst: &mut [u128]) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
pub fn read_i8_into(&mut self, dst: &mut [i8]) -> Result<(), Error>
[src]
pub fn read_i16_into<T>(&mut self, dst: &mut [i16]) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
pub fn read_i32_into<T>(&mut self, dst: &mut [i32]) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
pub fn read_i64_into<T>(&mut self, dst: &mut [i64]) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
pub fn read_i128_into<T>(&mut self, dst: &mut [i128]) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
pub fn read_f32_into<T>(&mut self, dst: &mut [f32]) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
pub fn read_f32_into_unchecked<T>(
&mut self,
dst: &mut [f32]
) -> Result<(), Error> where
T: ByteOrder,
[src]
&mut self,
dst: &mut [f32]
) -> Result<(), Error> where
T: ByteOrder,
pub fn read_f64_into<T>(&mut self, dst: &mut [f64]) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
pub fn read_f64_into_unchecked<T>(
&mut self,
dst: &mut [f64]
) -> Result<(), Error> where
T: ByteOrder,
[src]
&mut self,
dst: &mut [f64]
) -> Result<(), Error> where
T: ByteOrder,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,