- Seeking backwards after reading magic number, Mike Crawford (2016/08/31 00:22:47)
Greetings, I just subscribed. Thank you for your excellent library.The command-line tool I am developing can accept input in Zip, GZip or BZip2 formats, as well as uncompressed text. To enable that I read the first few bytes from the beginning of the input file; for Zip this is 'PK'.
This works fine if it is a regular file but I'd like to be able to read Zip from standard input; one cannot seek in a pipe. My GZip and BZip support handles this by placing those first few bytes in the input buffers that they use as a source of compressed data, but I don't see a way to do that with Zip.
I'm using the read(2) system call to avoid the overhead of stdio. With stdio, possibly it would work with fseek but I'd like to avoid stdio if I could - the input files can be quite large.
Is there - possibly a hacky - way to place a few bytes in the beginning of Zip's input buffer, as well as to adjust any offset counts?
I hope this makes sense. Mike Crawford Portland Software Development and Consulting http://soggywizards.com/ mike%soggywizards.com@localhost One Must Not Trifle With Wizards For It Makes Us Soggy And Hard To Light.
Made by MHonArc.