> > Basically, say I zip the folder: "c:\inetpub\wwwroot\test\this is a
> > test\". When I open the zip file it has the exact same folder
[quoted text clipped - 32 lines]
>
> -- chirs
Chris,
Thanks again very much for your response. I greatly appreciate your
help.
> So you are getting the absolute pathname of the file, and using that, unchanged
> except for replacing '\' with '/' as the name to use for the ZipEntry; am I
> understanding you correctly ?
Yes, you are correct
> Also, if I read you right, in both cases the directory and its contents are
> written to the zipfile, but the differences is that in the case where there are
> spaces in the directory name, the name that appears in the zipfile has several
> components (inetpub/wwwroot/test/this_is_a_test), but if the folder's name has
> no spaces, then all the ZipEntries are given shorter names without the
> "inetpub/wwwroot/test/" prefix ?
Yes and no. Yes, the directories and all of the contents are being
written to the zip file. No, the name is correct. I am creating a zip
file called test.zip from the directory c:\inetpub\wwwroot\test\this is
a test. When I extract this file to my desktop, I get the directory
structure desktop\inetpub\wwwroot\test\this is a test. This is
incorrect. It should be desktop\this is a test. If I use the directory
structure c:\inetpub\wwwroot\test\this_is_a_test. Everything works
fine. When I extract this file to the desktop, I get the directory
structue desktop\this_is_a_test.
> I think this must be a problem somewhere in the code you use to create the
> zipfile. I would add some tracing (or use a debugger) to find exactly what
> names your code is giving the ZipEntries. I'm pretty sure you'll find the
> problem there, i.e. that this is nothing to do with zip files themselves (or
> their Java implementation).
I will try this. Thanks for the suggestion.
> -- chirs
Again, thank you very much.
If you have any other suggestions I would greatly appreciate it.
Chris Uppal - 18 Oct 2006 12:27 GMT
[me:]
> > So you are getting the absolute pathname of the file, and using that,
> > unchanged except for replacing '\' with '/' as the name to use for the
> > ZipEntry; am I understanding you correctly ?
> Yes, you are correct
Then I think that's probably half your problem there. ZIP files are not meant
to contain "absolute" paths (think what would happen if a naive client
extracted 'C:\Windows\system32\somethingVital.dll' without checking, for
instance). Unless you are creating the ZIP file for very special purposes
(i.e. not the be read by a general reader) then each filename should be of the
form:
dir1/dir2/filename
where "dir1" does NOT start with '/'.
> When I extract this file to my desktop, I get the directory
> structure desktop\inetpub\wwwroot\test\this is a test. This is
> incorrect.
And I think that's the other half of your problem. The ZIP file reader which
is built into Windows XP (and later) is fairly deeply broken. For one thing it
(stupidly) attempts to interpret filenames with '\' in them (which probably
mislead you from the start), for another thing, it simply doesn't work with
entries including the ':' or ';' character in the filename. I'm sure it has
other problems too. This is why I kept asking what reader you were using. If
you use the unzip utility I mentioned, then you'll find out what is /actually/
in the ZIP file, not what MS's broken reader /thinks/ is in there.
I can't, by the way, reproduce exactly the symptoms you are seeing, so there
may be other problems still to be resolved, but I'd bet that the combo of
Windows and the ':' character is causing at least some of the problems.
-- chris