I have some file, there's some random bytes, and multiple gzip files. How can i find start and end of gzip stream inside the some file? there's many random bytes between gzip streams. So, basically i need to find any gzip file and get it from there.
相关问题
- What is the best way to do a search in a large fil
- Spring Integration - Inbound file endpoint. How to
- php--glob for searching directories and .jpg only
- Editing how file name is displayed in JComboBox wh
- how to create files under /WEB-INF/
相关文章
- What is the correct way to declare and use a FILE
- Making new files automatically executable?
- How to serialize data into indented json [duplicat
- Creating a custom file like object python suggesti
- Can I release an app without the device?
- Archive option greyed out in xcode 4.5.2
- Sorting a data stream before writing to file in no
- Fastest way to create files in C#
Reading from the RFC 1952 - GZIP :
Each GZIP file is just a bunch of data chunks (called members), one for each file contained.
Each member starts with the following bytes:
DEFLATE
d file. 0-7 are reserved values.The end of a member is not delimited. You have to actually walk the entire member. Note that concatenating multiple valid GZIP files creates a valid GZIP file. Also note that overshooting a member may still result in a successful reading of the member (unless the decompressing library is fail-eagerly-and-completely).
Search for a three-byte gzip signature, 0x1f 0x8b 0x08. When you find it, try to decode a gzip stream starting with the 0x1f. If you succeed, then that was a gzip stream, and it ended where it ended. Continue the search from after that gzip stream if it is one, or after the 0x08 if it isn't. Then you will find all of them and you will know their location and span.