Only decompress a specific bzip2 block

前端 未结 2 607
长发绾君心
长发绾君心 2020-12-30 09:54

Say I have a bzip2 file (over 5GB), and I want to decompress only block #x, because there is where my data is (block is different every time). How would I do this?

I

相关标签:
2条回答
  • 2020-12-30 10:09

    There is a http://bitbucket.org/james_taylor/seek-bzip2

    Grab the source, compile it.

    Run with

    ./seek-bzip2  32 < bzip_compressed.bz2 
    

    to test.

    the only param is bit displacement of wondered block header. You can get it with finding a "31 41 59 26 53 59 " hex string in the binary file. THIS WAS INCORRECT. Block start may be not aligned to byte boundary, so you should search for every possible bit shifts of "31 41 59 26 53 59" hex string, as it is done in bzip2recover - http://www.bzip.org/1.0.3/html/recovering.html

    32 is bit size of "BZh1" header where 1 can be any digit from "1" to "9" (in classic bzip2) - it is a (uncompressed) block size in hundreds of kb (not exact).

    0 讨论(0)
  • 2020-12-30 10:21

    It's true that bzip-table is almost as slow as decompressing but of course you only have to do it once and you can store the output in some fashion to use as an index. This is perfect for what I need but may not be what everybody needs.

    I did need a little help getting it to compile on Windows though.

    0 讨论(0)
提交回复
热议问题