Glynn Clements wrote: > Prasanta Sadhukhan wrote: > > >> Is it possible to output the content of a particular file from a zip file? >> For example, in the attached ziptest.c I want to get the contents of a >> particular file Class3.class from testclasses.zip into a buffer, can >> anyone point out what I need to change in the code? >> > > Iterate over the files until you find the right one. Either start by > locating the first local file header, then each subsequent one, or > locate the central directory and iterate over the file headers which > are stored there. > > For the first method, given the offset of one local file header, the > next one should be located 30 + "file name length" + "extra field length" > + "compressed size" + 12 bytes further on. > > For the second method, the offset from one entry to the next is > 46 + "file name length" + "extra field length" + "file comment length". > > The start of the central directory can be found from the end of > central directory record, which is at the end of the file. The length > is variable, so you have to scan backwards for the signature (50 4b 05 > 06), then verify that the offset is 22 + "ZIP file comment length" > bytes before the end of the file). > > Thanks. I tried finding the central directory and list the contents which I am now able to do. I got the match also but I am not sure how would I get the contents once I get the match. I tried fopen but it fails with "No such file or directory" Attached is my code Regards Prasanta