Skip to content

Commit

Permalink
Add contains_file_named
Browse files Browse the repository at this point in the history
  • Loading branch information
Pr0methean committed Apr 20, 2024
1 parent e4d0a02 commit 16b6684
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,4 +267,11 @@
### Changed

- Eliminated a custom `AtomicU64` type by replacing it with `OnceLock` in the only place it's used.
- `FileOptions` now has the subtype `SimpleFileOptions` which implements `Copy` but has no extra data.
- `FileOptions` now has the subtype `SimpleFileOptions` which implements `Copy` but has no extra data.

## [1.1.1]

### Added

- `contains_file_named`: check whether a file entry exists in a zip file, without initializing the
metadata or needing to mutably borrow the `ZipArchive`.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "zip"
version = "1.1.0"
version = "1.1.1"
authors = [
"Mathijs van de Nes <[email protected]>",
"Marli Frost <[email protected]>",
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ zip
[![Build Status](https://github.com/Pr0methean/zip-next/actions/workflows/ci.yaml/badge.svg)](https://github.com/Pr0methean/zip-next/actions?query=branch%3Amaster+workflow%3ACI)
[![Crates.io version](https://img.shields.io/crates/v/zip.svg)](https://crates.io/crates/zip)

[Documentation](https://docs.rs/zip/1.1.0/zip/)
[Documentation](https://docs.rs/zip/latest/zip/)

Info
----
Expand Down Expand Up @@ -33,14 +33,14 @@ With all default features:

```toml
[dependencies]
zip = "1.1.0"
zip = "1.1.1"
```

Without the default features:

```toml
[dependencies]
zip = { version = "1.1.0", default-features = false }
zip = { version = "1.1.1", default-features = false }
```

The features available are:
Expand All @@ -53,7 +53,8 @@ The features available are:
This is the fastest `deflate` implementation available.
* `deflate-zopfli`: Enables deflating files with the `zopfli` library (used when compression quality is 10..=264). This
is the most effective `deflate` implementation available.
* `deflate64`: Enables the deflate64 compression algorithm. Decompression is only supported.
* `deflate64`: Enables the deflate64 compression algorithm. Only decompression is supported.
* `lzma`: Enables the LZMA compression algorithm. Only decompression is supported.
* `bzip2`: Enables the BZip2 compression algorithm.
* `time`: Enables features using the [time](https://github.com/rust-lang-deprecated/time) crate.
* `chrono`: Enables converting last-modified `zip::DateTime` to and from `chrono::NaiveDateTime`.
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ mod zipcrypto;
///
/// ```toml
/// [dependencies]
/// zip = "=1.1.0"
/// zip = "=1.1.1"
/// ```
pub mod unstable;
5 changes: 5 additions & 0 deletions src/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,11 @@ impl<R: Read + Seek> ZipArchive<R> {
pub fn by_name(&mut self, name: &str) -> ZipResult<ZipFile> {
self.by_name_with_optional_password(name, None)
}

/// Check for a file entry, but do not decrypt it or initialize metadata.
pub fn contains_file_named(&self, name: &str) -> bool {
self.shared.names_map.contains_key(name)
}

fn by_name_with_optional_password<'a>(
&'a mut self,
Expand Down

0 comments on commit 16b6684

Please sign in to comment.