Comments (5)
I've been trying to compress / decompress a vector of bytes by feeding it into a BitOutputArchive or a BitInputArchive respectively.
Usually, you don't want to directly use BitOutputArchive
/BitInputArchive
, and should use BitArchiveWriter
/BitArchiveReader
instead. This is because the former classes need a separate BitAbstractArchiveCreator
/BitAbstractArchiveHandler
instance, while the writer and reader classes already implement these abstractions.
This was rejected as unpermitted operation.
What is the exact error message and error code thrown by bit7z?
Should I use BitMemoryCompressor?
BitMemCompressor
internally uses BitOutputArchive
, so it will likely behave exactly as this latter. In general, it is useful when you want to create multiple archives from memory data using the same compression settings/callbacks. In all other cases, e.g., creating only one archive, BitArchiveWriter
is the standard choice.
The same applies to the BitMemExtractor
vs BitArchiveReader
.
from bit7z.
Thank you for your time and your gracious help.
I tried the following:
bit7z::Bit7zLibrary lib{ LR"(C:\util\7z.dll)" };
void compress(const std::vector<bit7z::byte_t>& data, std::vector<bit7z::byte_t>& compressed)
{
try
{
bit7z::BitArchiveWriter writer(lib, bit7z::BitFormat::GZip);
writer.compressTo(compressed);
std::cout << "Compression succeeded!" << std::endl;
}
catch (bit7z::BitException ex)
{
std::cout << "Compression failed! " << ex.what() << std::endl;
}
}
This throws an exception in compressTo()
.
Within writer.compressTo()
, the exception is thrown in compressOut()
.
Variable outMemStream
might be the culprit.
Result of outArc->UpdateItems()
is E_INVALIDARG One or more arguments are invalid
.
from bit7z.
The problem is that, in your function, you're not adding any data to the archive (e.g., using writer.addFile(data, "filename")
).
7-Zip doesn't support creating empty GZip archives, hence your error.
Also, the GZip format itself doesn't allow adding more than one file, so only one file/buffer of data can be added to the archive; otherwise, a similar error will be thrown by the compressTo
method.
from bit7z.
That makes sense. Thank you again!
I've now managed to make it work.
Please find my code attached as example usage of bit7z
.
from bit7z.
That makes sense. Thank you again!
No problem!
As a side note, I definitely need to improve the error message and code in such cases, as 7-Zip is really not good at reporting the causes of such errors, unfortunately.
Please find my code attached as example usage of bit7z.
I took a look at your code and it seems fine to me.
Just a note: BitArchiveReader
can directly extract to a buffer, so the decompression function can be simplified as follows
void BZip7::decompress(const std::vector<bit7z::byte_t>& data, std::vector<bit7z::byte_t>& decompressed) const
{
try
{
bit7z::BitArchiveReader reader(lib, data, bit7z::BitFormat::GZip);
reader.extractTo(decompressed);
std::cout << "Decompression succeeded!" << std::endl;
}
catch (bit7z::BitException ex)
{
std::cout << "Decompression failed! " << ex.what() << std::endl;
}
}
from bit7z.
Related Issues (20)
- [Bug]: core dump with BitArchiveWriter HOT 9
- [Bug]: Some zip file names are garbled HOT 5
- [Bug]: HOT 3
- [Possible Bug]: BitArchiveReader::items is slow? HOT 6
- [Feature Request]: Link static 7z lib HOT 1
- [Bug]: Inconsistent encoding of string parameter HOT 1
- [Bug]: "Failed to open the output file: The system cannot find the path specified" error when extracting 7z file HOT 3
- [Feature Request]: VS2010 HOT 3
- [Feature Request]: Compare with 7zr.exe HOT 4
- [Bug]: Mingw cross compile fails HOT 2
- [Feature Request]: Compressing large folders,For example, compressing the entire D: drive HOT 19
- [Feature Request]: When using the same compression parameters as 7-zip, the compression process can be 10% - 20% slower. HOT 11
- [Feature Request]: BitOutputArchive::addFiles( const tstring& in_dir... should take options.only_files from an argument instead of 'false' HOT 6
- [Feature Request]: case insensitive path comparison option for Windows HOT 6
- Failed to compile on FreeBSD HOT 1
- Access Denied exception in BitOutputArchive::compressToFile HOT 4
- Unable to create archive in .bz2 or .xz formats HOT 3
- Opening Tar file with Zip format does not fail HOT 2
- Auto-detect archive format fails if the file extension does not match the actual file format HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bit7z.