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

FastZip does not allow Extended Path Filter to be specified #405

Closed
atcobb01 opened this issue Dec 30, 2019 · 4 comments
Closed

FastZip does not allow Extended Path Filter to be specified #405

atcobb01 opened this issue Dec 30, 2019 · 4 comments
Assignees
Labels
documentation question zip Related to ZIP file format

Comments

@atcobb01
Copy link

Version of SharpZipLib: 1.2.0

trying to use Extended Path Filter, but don't see any examples. FastZip uses strings for Name and Directory filters, but I need file time as a criteria. I don't see how to use the ExtendedPathFilter class when creating a zip file using FastZip or any other method. Can you help?

@piksel
Copy link
Member

piksel commented Dec 30, 2019

No, there does not seem to be any way to provide custom filters for FastZip. I'm not sure about what the purpose of ExtendedPathFilter is. It looks like it's meant to be used in FastZip, perhaps with an overloaded constructor. That should be a pretty small PR.

Otherwise, your use case could be achieved fairly easily with ZipFile like this:

using (var zf = new ZipFile(zipFileName)) {
    zf.BeginUpdate();
    var yesterday = DateTime.UtcNow.AddDays(-1);
    var files = Directory.GetFiles(sourceDir)
        .Where(f => new FileInfo(f).LastWriteTimeUtc > yesterday);
        
    foreach(var file in files){
        // Provide an entry name as a second parameter 
        // to avoid using the full path to the file
        var entryName = Path.GetFileName(file);
        zf.Add(file, entryName);
    }
    zf.CommitUpdate();
}

@Numpsy
Copy link
Contributor

Numpsy commented Jun 28, 2020

Maybe an extra version of CreateZip that takes the file/directory filters as IScanFilter rather than strings?

It looks like FileSystemScanner already has a constructor that can take a pair of IScanFilters on top of the one that uses strings (currently used by FastZip), so maybe that's a straight forward way of passing in alternate filter implementations?

@piksel piksel changed the title Extended Path Filter FastZip does not allow Extended Path Filter to be specified Aug 4, 2020
@piksel piksel self-assigned this Aug 4, 2020
@piksel piksel added the zip Related to ZIP file format label Aug 4, 2020
@Numpsy
Copy link
Contributor

Numpsy commented Aug 9, 2020

#482 allows alternate filters to be specified for CreateZip, though doesn't change the Extract functions.

@piksel
Copy link
Member

piksel commented Nov 21, 2020

This should be fixed by #482.

@piksel piksel closed this as completed Nov 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation question zip Related to ZIP file format
Projects
None yet
Development

No branches or pull requests

3 participants