|
|
renaming files in a zip archive without uncompressing?
I'm trying to write a (Win32) command line utility that can rename
files within a zip archive without decompressing or recompressing the
contents. I'd like to use zlib.
I'm not particularly familiar with the ins and outs of zlib or even
how the names are stored within the zip archive. But before I begin,
I'd like to know if this something that be done easily or at all?
any thoughts, tips, or links to sample code would be appreciated
thanks
....
Krick
|
|
0
|
|
|
|
Reply
|
wkrick
|
11/27/2004 8:15:47 AM |
|
Hi William
ZLib is a compression library and not a zip archive support library, so
while it will easily handle the actual compression of data, you will have to
add your own code to manipulate zip files.
The ZLib distribution contains some 3rd Party source code, some of which do
support zip files.
However, if all you are interested in doing is renaming files within the zip
archive, then you do not need ZLib as you will not need to compress any
data.
You might want to look at other options as there is plenty of freely
available source code to do this. Just do a web search.
regards
Mike
"William Krick" <wkrick@gmail.com> wrote in message
news:c08557e4.0411270015.62eade37@posting.google.com...
> I'm trying to write a (Win32) command line utility that can rename
> files within a zip archive without decompressing or recompressing the
> contents. I'd like to use zlib.
>
> I'm not particularly familiar with the ins and outs of zlib or even
> how the names are stored within the zip archive. But before I begin,
> I'd like to know if this something that be done easily or at all?
>
> any thoughts, tips, or links to sample code would be appreciated
>
> thanks
> ...
> Krick
|
|
0
|
|
|
|
Reply
|
Mike
|
11/27/2004 9:52:39 AM
|
|
wkrick@gmail.com (William Krick) wrote in message news:<c08557e4.0411270015.62eade37@posting.google.com>...
> I'm trying to write a (Win32) command line utility that can rename
> files within a zip archive without decompressing or recompressing the
> contents. I'd like to use zlib.
All that zlib can do for you is uncompress and compress. So you will
have succeeded in your objective if you make no use of zlib
whatsoever!
It should be relatively straightforward to modify the filenames in a
zip file, while changing nothing else, at least if the central
directory isn't encrypted. The only part that will require some care
is updating the relative offsets of the local headers in the central
headers, since the new filenames will in general be a different length
than the old filenames. Those offsets may be in a zip64 extra field
for large zip files. Also it's not trivial to find the central
directory without decompressing entries in the somewhat broken zip
file format, but it can be done (see Info-ZIP's unzip).
What you need to do is get the appnote from pkware.com which has the
latest description of the zipfile format.
mark
|
|
0
|
|
|
|
Reply
|
madler
|
11/27/2004 3:45:41 PM
|
|
madler@alumni.caltech.edu (Mark Adler) wrote in message news:<7ab39013.0411270745.2056fca9@posting.google.com>...
> wkrick@gmail.com (William Krick) wrote in message news:<c08557e4.0411270015.62eade37@posting.google.com>...
> > I'm trying to write a (Win32) command line utility that can rename
> > files within a zip archive without decompressing or recompressing the
> > contents.
>
> It should be relatively straightforward to modify the filenames in a
> zip file, while changing nothing else, at least if the central
> directory isn't encrypted. The only part that will require some care
> is updating the relative offsets of the local headers in the central
> headers, since the new filenames will in general be a different length
> than the old filenames. Those offsets may be in a zip64 extra field
> for large zip files. Also it's not trivial to find the central
> directory without decompressing entries in the somewhat broken zip
> file format, but it can be done (see Info-ZIP's unzip).
>
> What you need to do is get the appnote from pkware.com which has the
> latest description of the zipfile format.
>
> mark
Fortunately, I only need to support PKZip 2.04g compatible zip files
(deflate only) so I can safely ignore the "extensions" to the zip
format. I don't need to support encrypted files or anything like that
either.
|
|
0
|
|
|
|
Reply
|
wkrick
|
11/30/2004 7:14:18 PM
|
|
|
3 Replies
2245 Views
(page loaded in 0.067 seconds)
|
|
|
|
|
|
|
|
|