Skip Menu |

This queue is for tickets about the JSAN-Client CPAN distribution.

Report information
The Basics
Id: 16860
Status: new
Priority: 0/
Queue: JSAN-Client

People
Owner: Nobody in particular
Requestors: adamk [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Patch to add zip support
Adam, here's a patch that adds support for Zips to JSAN::Client version 0.10. I added this so I could install Mochikit with the Catalyst JSAN helper. Hope you find it useful. Thanks, Kenny --- Release.pm.orig 2005-08-30 00:40:24.000000000 -0400 +++ Release.pm 2006-01-01 15:54:53.000000000 -0500 @@ -298,7 +298,37 @@ } sub _extract_resource_from_zip { - Carp::croak("Zip support not yet completed"); + my ($self, $resource, %params) = @_; + my $zip = $self->archive; + my @files = $zip->members(); + + # Determine which files to extract, and to where + my $extracted_files = 0; + for my $item ( @files) { + # Split into parts and remove the top level dir + my ($vol, $dir, $file) + = File::Spec::Unix->splitpath($item->fileName); + my @dirs = File::Spec::Unix->splitdir($dir); + shift @dirs; + + # Is this file in the resource directory + my $res = shift(@dirs) or next; + next unless $res eq $resource; + + # These are STILL relative, but we'll deal with that later. + my $write_dir = File::Spec->catfile($params{to}, @dirs); + + # Write the file + $self->_write( $write_dir, $file, $item->contents() ); + $extracted_files++; + + } + + # Return the number of files, or error if none + return $extracted_files if $extracted_files; + my $path = $self->source; + Carp::croak("Zip '$path' does not contain resource '$resource'"); + } sub _write {