Boost filter_istream gzip_decompressor uncompressed file size

I am using a filter filter flow object to read gzipped files. Works great! I would like to display a progress bar for the volume of the file that has been processed. I need to find the size of an uncompressed input file. Does the gzip unpacker have the original file size from the gzip file? I could not find it on the enlarge gzip_decompressor reference page . Actually the progress dialog is the goal, is there any other way to determine the position in the compressed file?

    // gets compressed file size, need uncompressed size
    boost::uintmax_t fs = boost::filesystem::file_size (
        boost::filesystem::path (fname)
        );

    std::ifstream file (fname, std::ios_base::in | std::ios_base::binary);
    boost::iostreams::filtering_istream in;
    in.push (boost::iostreams::gzip_decompressor());
    in.push (file);

    std::string line;
    size_t bytes_read = 0;
    while (in)
    {
        std::getline (in, line);
        bytes_read += line.size ();
        // progress dlg with bytes_read / uncompressed size
    }
+3
source share
1 answer

, , ( 4 gzip (. GZIP spec), boost (. ), . , , , , , , read_footer . ( 4 int, (. GZIP )) , .

+4

Source: https://habr.com/ru/post/1723360/


All Articles