Hi all,
I need code for opening a zip file (not extracting it) and reading the contents of the zip file.
Pls help...
Thanks in advance
Hi all,
I need code for opening a zip file (not extracting it) and reading the contents of the zip file.
Pls help...
Thanks in advance
You can open it in binary mode, as you can do every file. You use b in fopen arguments, like wb, rb instead of r, w.
Binary files are a sequence of 0 and 1. Text files are sequence of bytes that represent a character (usually an ASCII character).
zip files are not different, you just need to know what you are doing (as always)
There is no difference between binary and text files.Binary files are a sequence of 0 and 1. Text files are sequence of bytes
Any file could be opened in the binary or text mode.
In binary mode file is read as is.
In text mode some conversions are done. Conversion depends on the OS.
On windows, for example, 0x0D 0x0A sequence of bytes indicating the end-of line is replace with one character \n while reading, and back - when writing.
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
guys i need 2 know how i can read the contents of a zip file without extracting it.
well..now the picture's clear..aha
No, it is not clear.
Do you need to fill buffer with the compressed contents of the zip-file?
Do you want to extract the file list without extracting the files?
Do you want to extract some file from the archive without extracting archive?
Do you want to extract archive without using external programs?
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
sorry boss..lets make it clear now..
want to extract the file list without extracting the files? (first)
and then..
want to read the files from the archive without extracting archive?
pls reply
This should be possible. I have little knowledge of the archive format, but the Wikipedia article claims that "the location of a file is indicated in the so called central directory which is located at the end of the ZIP file". As such, following the format specification you can get to that central directory and read it.Originally Posted by smooth
This sounds impossible by definition.Originally Posted by smooth
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Whilst Laserlight says it's impossible, I don't quite agree - you could decompress the content into memory without actually generating a file from it. However, on a scale 1..10, where 1 is simple and 10 is highly complex, I'd put this around 8.
A much easier task would be to find a zip compatible library, and write some code to interface what you want into that archive.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
I equated "extract" with "decompress".Originally Posted by matsp
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)