It does by implementing a fake filehandle that supports seek, implemented by using the FTP REST and ABOR commands to start the download at an arbitrary point, and end it when we've read all we want. Some FTP servers will disconnect you if you ABORt a transfer, but [cpan://Net::FTP::AutoReconnect] will re-connect as if nothing happened. When [cpan://Archive::Zip] is asked to open an archive on the fake filehandle, it doesn't even know what hit it.
Here's some sample code using these modules:
#!/usr/bin/perl
use warnings;
use strict;
use Net::FTP;
use Net::FTP::AutoReconnect;
use Net::FTP::RetrHandle;
use Archive::Zip;
my $ftp = Net::FTP::AutoReconnect->new("ftp.info-zip.com", Debug => $ENV{DEBUG})
or die "connect error\n";
$ftp->login('anonymous','example@example.com')
or die "login error\n";
$ftp->cwd('/pub/infozip/UNIX/LINUX')
or die "cwd error\n";
my $fh = Net::FTP::RetrHandle->new($ftp,'unz551x-glibc.zip')
or die "Couldn't get handle to remote file\n";
my $zip = Archive::Zip->new($fh)
or die "Couldn't create Zip object\n";
foreach my $fn ($zip->memberNames())
{
print "unz551-glibc.zip: $fn\n";
}
Sorry for the bit of tooting my own horn, but this was such a fun hack I had to tell somebody, and I thought that My Fellow Monks would appreciate it. :)
perlmonks.org content © perlmonks.org and Ace128, sgifford
prlmnks.org © 2006 edmund von der burg (eccles & toad)
v 0.03