Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

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

Report this thread to moderator Post Follow-up to this message
Old Post
William Krick
11-27-04 01:55 PM


Re: renaming files in a zip archive without uncompressing?
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



Report this thread to moderator Post Follow-up to this message
Old Post
Mike B
11-27-04 01:55 PM


Re: renaming files in a zip archive without uncompressing?
wkrick@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

Report this thread to moderator Post Follow-up to this message
Old Post
Mark Adler
11-27-04 08:55 PM


Re: renaming files in a zip archive without uncompressing?
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.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.

Report this thread to moderator Post Follow-up to this message
Old Post
William Krick
12-01-04 01:55 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Compression archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 06:53 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.