On Wed Dec 07 09:36:36 2011, GRAF wrote:
Show quoted text> > If you don't mind my asking, in your use-case does the directory name
> > you
> > are adding to the Zip file actually correspond to a real directory in
> > the file system? So if there was an addDirectory method, like this
> >
> > $zip->addDirectory("/some/directory");
> >
> > it would create the directory in the zip file with the trailing "/",
> > plus
> > it would get the file attributes from the real directory. It would
> > also
> > fail if the directory doesn't exist.
>
> Actually the directory does exist in my case, but in general making this
> a requirement would be a bad concept, because the data you store in an
> archive with IO::Compress does not necessarily have to exist somewhere
> on the file system.
I agree that there are two use-cases. One is where you want to add a
directory that mirrors something that exists on a filesyetem. The second
use case is where it gets created in code. I suspect the former would be
the predominant use-case, but don't want to restrict it to that.
Show quoted text> Moreover creating a directory entry in the archive is not required by
> ZIP at all: unzip will create all required directories when unpacking
> files. The only use-case for explicit directories in ZIP archives, that
> I'm aware of, is to define permission bits for it.
Yep - that's what I've found as well.
Show quoted text> My suggestion is to fix sub canonicalName in a way to not chop a
> trailing '/' in path names, because - as I said - this has a special
> meaning for ZIP.
Show quoted text> I'm attaching a patch, that implements that behaviour.
Part of the reason for doing CanonocalName was to make it more difficult
for folk to get unexpected results.
$zip->newStream( Name => 'myfile/') ;
print $zip "some data";
In the above the user thinks they have created an entry in the zip file
that stores the payload "some data". A commanline unzip will show the
length of the stored data correctly, but if they unzip it with a command
line unzipper they end up with a directory called "myFile", rather than
a file that contains "some data".
Paul