-
Notifications
You must be signed in to change notification settings - Fork 316
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
How to add multiple files and folders at once? #84
Comments
To answer the two questions:
Both the code samples above should work but are not tested by me. I wrote the code here directly, so there might be some syntax errors. But I think you get the idea. Both of these points are good candidates for new features. The first one might be slightly complicated from an api perspective, but I will consider adding them in one of the next releases. |
I added a folder with the same name in zip, it is very slow, how should I speed it up? If there is no folder with the same name in the archive, adding the file will be quick. Adding a folder with the same name takes one minute, adding a folder without a name takes only three seconds. |
I tested with adding the same folder to a zip file more than once. It only takes slight more time when the folder already exists in zip file. When adding a file to a archive which containes a file with same name, zip4j will by default override the same name file(so are the folders). That means the zip4j will firstly remove the existing file in the archive, then add the new file. That's why adding a file to a archive which containes a file with same name takes more time. If you do not want to override the same name file in zip, you can do it like this
|
I see multiple ideas for new features here in zip4j:
I will include these features in one of the next release (hopefully in the next release if time permits) |
Hey bro, this is great! I waiting for your release! |
I may have a related request. We are trying to zip up multiple files in multiple different folder locations, retaining the folder hierarchy, and utilizing the split zip functionality to keep zip sizes under 4GB. I don't currently see a way to accomplish this. Is there a workaround? |
@markgbrown Your requirement is to create a zip file with:
Unfortunately, a combination of all 3 is not possible at the moment. You can choose any 2 of the 3, but unfortunately, not all 3 together. |
@srikanth-lingala I have implemented a solution that works for us for this scenario. It allows the files in the zip to retain the same folder hierarchy as the input files. If you are interested in the solution, I can send you the files that changed and you can decide whether it makes sense to incorporate into the library. I've never had the chance to contribute to open source before, so let me know what works best. |
@markgbrown Sure, please send me a patch or a PR and I will have a look into it. Just to be clear, when I said |
Here's a pull request for you to look at. Feel free to use any or none of it as you feel appropriate. |
我觉得添加文件或文件夹能否别拆开,在程序内部进行判断,因为当我想获取一个ProgressMonitor进度监听器的时候,并不能够同时监听两个进程的任务 |
These two features have been added in the branch
I will merge it to master and include it in the next release. Working on the third feature:
|
The last feature
is a bit complicated and tricky to implement. This will also break backward compatibility. It might be that there are users of zip4j adding files to a zip which is a directory and not expecting the whole directory to be added. If this change is now done, it might break their logic. And also there are some complicated questions of what the rootDirectory of the file (which is a folder) should be because the root directory of this file can be different than the other files being added. The other two features:
have long been implemented and released |
What should I do to compress multiple files and multiple folders into the root directory? Single compression seems to be very slow, can you compress multiple files and multiple folders at once?
like this?
Also, how to delete the folder inside the archive, the api seems to only provide the delete file.
The text was updated successfully, but these errors were encountered: