[bcn-pm] patch pel Net::FTP

pancake pancake at phreaker.net
Fri Oct 1 03:32:14 CDT 2004


he fet un patch pel Net::FTP q pel q estic fent (uuh misteri) va força be. l tema sq et permet definit un limit, es a dir baixar un fitxer a parts, dir l'inici i el final d'aquest. L'he enviat a l'autor i estic esperant resposta.

--- /usr/pkg/lib/perl5/5.8.4/Net/FTP.pm 2004-08-01 19:14:36.000000000 -0400
+++ /tmp/Net/FTP.pm     2004-10-01 04:26:33.000000000 -0400
@@ -430,9 +430,9 @@
 
 sub get
 {
- my($ftp,$remote,$local,$where) = @_;
+ my($ftp,$remote,$local,$where,$limit) = @_;
 
- my($loc,$len,$buf,$resp,$data);
+ my($loc,$len,$buf,$resp,$data,$flen,$eof);
  local *FD;
 
  my $localfd = ref($local) || ref(\$local) eq "GLOB";
@@ -485,10 +485,21 @@
  my $blksize = ${*$ftp}{'net_ftp_blksize'};
  local $\; # Just in case
 
- while(1)
+ $flen=0;
+ $eof=0;
+ while(!$eof)
   {
    last unless $len = $data->read($buf,$blksize);
 
+   if (defined($limit))
+   {
+    $flen+=$len;
+    if ($flen>$limit)
+     {
+      $len=$flen-$limit; 
+      $eof=1;
+     }
+   }
    if (trEBCDIC && $ftp->type ne 'I')
     {
      $buf = $ftp->toebcdic($buf);



More information about the Barcelona-pm mailing list