Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for setting per-item FileOptions (mapping) #13

Merged

Conversation

m4heshd
Copy link
Contributor

@m4heshd m4heshd commented Apr 10, 2024

This PR implements the feature discussed in #12, allowing an instance of FileOptions to be set for each file or directory processed by create_from_directory_with_options(). As mentioned there, this API refactor would be a breaking change.

Current usage of the API:

let mut zip = ZipWriter::new(file);

// This has the limitation of only allowing one configuration for all the files and directories.
zip.create_from_directory_with_options(
    &PathBuf::from(&source_dir),
    FileOptions::default(),
);

API usage with this PR:

let mut zip = ZipWriter::new(file);

zip.create_from_directory_with_options(&PathBuf::from(&source_dir), |file: &PathBuf| {
    if file.eq(&PathBuf::from("dir/my_executable")) {
        FileOptions::default().unix_permissions(0o775)
    } else {
        FileOptions::default()
    }
});

@matzefriedrich matzefriedrich self-assigned this Apr 17, 2024
@matzefriedrich matzefriedrich added the enhancement New feature or request label Apr 17, 2024
@matzefriedrich matzefriedrich changed the base branch from master to develop May 31, 2024 22:08
@matzefriedrich matzefriedrich merged commit 33741aa into matzefriedrich:develop May 31, 2024
1 check passed
@matzefriedrich matzefriedrich linked an issue May 31, 2024 that may be closed by this pull request
matzefriedrich added a commit that referenced this pull request May 31, 2024
* Add support for setting per-item `FileOptions` (mapping) (#13)

* Upgrades the zip dependency to version 0.6.6

* Updates the crate version

* Adds a CHANGELOG file

---------

Co-authored-by: Mahesh Bandara Wijerathna <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FileOptions should be mappable
2 participants