Code Comments
Programming Forum and web based access to our favorite programming groups.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
Post Follow-up to this messageHi 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
Post Follow-up to this messagewkrick@gmail.com (William Krick) wrote in message news:<c08557e4.0411270015.62eade37@postin g.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
Post Follow-up to this messagemadler@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.041127001 5.62eade37@posting.google.com>... > > 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.
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.