Add 7z archive writer with LZMA/LZMA2 compression#1229
Add 7z archive writer with LZMA/LZMA2 compression#1229adamhathcock merged 14 commits intoadamhathcock:masterfrom
Conversation
…, CRC dedup, exception filter
Code Review SummaryStatus: 1 Active Issue | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Note: The issue has been partially addressed with a rewind fix at lines 106-107 that erases orphaned encoder bytes when empty streams are detected. The author indicated they will extend this with byte probe later. Files Reviewed (14 files)
Assessment: The implementation is well-structured with solid test coverage. The existing warning at line 97 has been partially addressed with the rewind fix. Consider verifying the empty stream handling works correctly with non-seekable streams before merging. |
|
This is great, I'll have to inspect hits closely I was close to merging in a new PR that changes the API just for 7z files because you can't really do random access of bytes (extract them) as it's likely there's multiple files in a single stream. I'm interested in how you handled it. |
|
Looks like it's just the writer and does a compresssion stream per file. I'll sleep on it but probably want to take it as-is if the tests pass! |
Yes it doesn't do solid archives yet, I honestly didn't want to add everything at once - just to make PR easier to comprehend |
Summary
Adds write support for 7z archives. Files can be compressed with LZMA or LZMA2 (default). Each file is compressed independently (non-solid mode). Archives produced pass
7z tvalidation and open correctly in 7-Zip GUI.The writer plugs into the existing
WriterFactory/SevenZipFactoryinfrastructure and supports both sync and async APIs.SevenZipWriterOptionscontrols compression type, header compression, and LZMA encoder settings.Also adds
LZMA2to theCompressionTypeenum and aLzma2EncoderStreamthat implements chunk-based LZMA2 framing on top of the existing LZMA encoder.What's not included (but will/can add what i can if this PR will be accepted)
IWritableArchiveintegrationTask.Runin library code, which just hides threading from the caller. Open to ideas if there's a better approach.Testing
Round-trip tests cover single/multiple files, directories, empty files, large data, both compression methods, compressed and uncompressed headers, and factory-based creation. Tests pass on net10.0 and net48. Archives also verified externally with 7-Zip.