> After a bit of investigating, I think this problem might be due to the
> fact that there are spaces in the path name for files contained in the
> ZIP file.
Spaces in filenames /shouldn't/ cause problems. They don't on my system
(XP-pro but without SP2).
> We don't actually need the path to be in the ZIP file so this begs the
> question: how does one put ZipEntries into a ZipFile *without* the path
> information being retained from the original Files' path on the file
> system?
Hmm, how are you creating the zip file ? With the Java ZIP implementation
(java.util.zip.ZipOutputStream and friends) ? If so then it should be pretty
obvious -- just set the name to whatever you want (but ensure that it's unique)
when you add the data.
If not then you are using some other tool or library, and I don't know what its
capabilities might be. I wouldn't be surprised to find that you are using a
utility that can only create ZIP files by adding actual files from the
filesystem, rather than a library that creates ZIP format data in memory out of
other data that is also held in memory. The first approach seems to be the
most common even for code libraries (and is the only one possible for external
utilities, of course).
What do you mean by the 'path information' ? If you are building ZIP files
with embedded filenames like
"C:\this is a test\something.pdf"
then that won't work -- ':' is one of the special characters, and '/' is the
correct separator, not '\' (though Windows does seem to interpret '\' as a
separator in ZIP files). Anyway you don't want even to /think/ about embedding
/absolute/ paths in a ZIP file. The filename should be something like:
"top level/sub dir/something.pdf"
or, merely:
"something.pdf"
Whatever tool you are using should certainly have some way to control this
aspect of how it works -- if not then ditch it.
Another thing that occurs to me is that if you are building your ZIP data from
real files, then the tool you are using to do it may be adding data that
Windows interprets as file-system permissions (probably copied from the source
PDF files). The basic permissions are essentially those of DOS/FAT, and one of
the permission flags says that the file is 'hidden', another marks it as being
a 'system' file. It may be that the entries in the ZIP file have one or other
of these flags set, and that Windows is attempting to honour them (it doesn't
on my system, but then I don't have SP2, and I don't let Windows hide 'hidden'
and 'system' files anyway). There is also a more elaborate extended (and
optional) set of file permissions that can be set, and which may have a similar
effect, but I don't know anything much about that aspect of the system.
-- chris
Robbie - 10 May 2005 10:11 GMT
> Spaces in filenames /shouldn't/ cause problems. They don't on my system
> (XP-pro but without SP2).
I think you're probably right - but we want to remove this possibility.
> Hmm, how are you creating the zip file ? With the Java ZIP implementation
> (java.util.zip.ZipOutputStream and friends) ? If so then it should be pretty
> obvious -- just set the name to whatever you want (but ensure that
> it's unique) when you add the data.
Yes, apologies for that, we are using java.util.zip so we will just
change the name of the file being added.
After your suggestion to use zipinfo to compare WinZip files and files
generated by java.util.zip we did identify some differences and we
still have the problem after removing the path I'll post these to see
whether anyone can spot the differences that are preventing Windows XP
from opening the file.
Thanks again for the input.
Robbie