in reply to Archive::Zip problem with Windows Explorer
I assume that Windows Explorer is using the strict interpretation of the zip spec.4.4.17.1 The name of the file, with optional relative path. The path stored MUST not contain a drive or device letter, or a leading slash. All slashes MUST be forward slashes '/' as opposed to backwards slashes '\' for compatibility with Amiga and UNIX file systems etc. If input came from standard input, there is no file name field.
The Archive::Zip docs do cover this in the addFile section
As mentioned already in Re: Archive::Zip problem with Windows Explorer Windows Explorer can display both the path & filename if it uses a relative path.NOTE that you should not (generally) use absolute path names in zip member names, as this will cause problems with some zip tools as well as introduce a security hole and make the zip harder to use.
Something like this (untested) should allow you to store your files using a relative path.
foreach my $href ( @files_to_get ) { my $file = $href->{"files"}; print( " adding $file\n" ); my $name = $file; $name =~ s/^[A-Z]://; # remove drive $name =~ s#^[/\\]+##; # remove leading path delimiter $zip->addFile( $file, $name ); }
|
|---|