Closed chifandeyu closed 2 years ago
Hi! Could you be more specific? What do you mean by "extract result"?
Sorry, I didn't describe it clearly. I want to listen to the total progress when extracting archive file. And whether the decompression is successful.
Sorry, I didn't describe it clearly.
No problem!
I want to listen to the total progress when extracting archive file.
You have to set both the total size and the progress size callbacks. You can use the setter functions BitExtractor::setTotalCallback
and BitExtractor::setProgressCallback
.
E.g.:
//...
uint64_t total = 0; // We need a global total variable in order to calculate the progress percentage
extractor.setTotalCallback([this, &total](uint64_t total_size) {
total_size = total; // It will be called only once at the start of the extraction process.
});
extractor.setProgressCallback([this, &total](uint64_t progress_size) {
std::cout << "Extracting... "
<< static_cast<int>( ( 100.0 * progress_size ) / total ) << "%" << std::endl;
});
//...
And whether the decompression is successful.
If the extraction function of BitExtractor
finishes without throwing exceptions, it means that the decompression was successful. Otherwise, the function will throw a BitException
object.
Sorry, I didn't describe it clearly.
No problem!
I want to listen to the total progress when extracting archive file.
You have to set both the total size and the progress size callbacks. You can use the setter functions
BitExtractor::setTotalCallback
andBitExtractor::setProgressCallback
. E.g.://... uint64_t total = 0; // We need a global total variable in order to calculate the progress percentage extractor.setTotalCallback([this, &total](uint64_t total_size) { total_size = total; // It will be called only once at the start of the extraction process. }); extractor.setProgressCallback([this, &total](uint64_t progress_size) { std::cout << "Extracting... " << static_cast<int>( ( 100.0 * progress_size ) / total ) << "%" << std::endl; }); //...
And whether the decompression is successful.
If the extraction function of
BitExtractor
finishes without throwing exceptions, it means that the decompression was successful. Otherwise, the function will throw aBitException
object.
👍That's great! Thx.
Feature description
Can get extract result when extract finish?
Additional context
No response
Code of Conduct