rikyoz / bit7z

A C++ static library offering a clean and simple interface to the 7-zip shared libraries.
https://rikyoz.github.io/bit7z
Mozilla Public License 2.0
634 stars 116 forks source link

[Feature Request]: bitCompressor with update = false should recreate the archive #95

Closed cobian-test closed 1 year ago

cobian-test commented 2 years ago

Feature description

The behavior right now is that if compressor.setUpdateMode(false); and the archive already exists, an exception is thrown. It could be easy to fix by checking the existence of the file and deleting the archive before opening the output stream. The same (and most important) thing should be done if creating volumes, because every existing part raises an exception now.

Regards

Additional context

No response

Code of Conduct

rikyoz commented 2 years ago

Hi!

The behavior right now is that if compressor.setUpdateMode(false); and the archive already exists, an exception is thrown.

This behavior is actually going to change with the next version (currently in beta). The setUpdateMode will not accept a boolean parameter anymore, but rather an enum value which can be one from UpdateMode::None, UpdateMode::Overwrite, and UpdateMode::Append.

It could be easy to fix by checking the existence of the file and deleting the archive before opening the output stream. The same (and most important) thing should be done if creating volumes, because every existing part raises an exception now.

I think it might be really useful, thanks for your suggestion! The only problem I can see is that deleting the already existing archive might not be the best default behavior desirable by the library's user. So what I'm probably going to do is add another update mode to the next version, something like UpdateMode::OverwriteArchive, which should make bit7z behave just like you suggested.

rikyoz commented 1 year ago

Implemented in v4.0.0