Closed vladimir-kraus closed 11 months ago
Hi!
The title speaks for itself: is it possible to remove/delete items directly from existing archive?
Unfortunately, no, at least with the current stable version (v3.1.4).
However, it will be possible with the next major version (v4.0).
It's actually already implemented in a new class called BitArchiveEditor
, which allows editing already existing archives. It allows to add, delete, update, and rename the items in the archive.
By "directly" I mean without extracting the archive first to temporary folder on a disk, then removing the items from the disk and compressing it again.
The removal of the file will be "direct" because the class will not perform any extraction. However, the class has the same behaviour as 7-zip, i.e., it creates a temporary archive where 7-zip copies all the compressed data but the item(s) to be deleted.
If you're interested in the API, please check https://github.com/rikyoz/bit7z/blob/pre-release/v4.0.0-beta/include/bitarchiveeditor.hpp. Roughly, it will be possible to use some code like the following:
BitArchiveEditor editor{ lib, L"path/to/archive.7z", BitFormat::SevenZip };
editor.deleteItem(L"folder/compressed_file.txt"); // path of the file to be deleted from the archive
editor.applyChanges();
Note: the actual deletion only happens when you call the applyChanges()
method; in this way, you can chain multiple edit operations and apply them all together to the archive.
Feature description
The title speaks for itself: is it possible to remove/delete items directly from existing archive?
By "directly" I mean without extracting the archive first to temporary folder on a disk, then removing the items from the disk and compressing it again.
After experimenting with 7z command line tool, it seems to me that 7zip is able to do this. There is a command option for this https://sevenzip.osdn.jp/chm/cmdline/commands/delete.htm and by observing the speed of this operation, it definitely is faster than extracting and compressing back.
Additional context
No response
Code of Conduct