Hello,

The attached patch allows specifying a directory as lwp-download's
second argument.  Also makes "0" valid destination file name.


PS  Please Cc me with eventual replies, I don't subscribe this list.

-- 
Radosław Zieliński <[EMAIL PROTECTED]>
[ GPG key: http://radek.karnet.pl/ ]
--- bin/lwp-download    2004-11-14 07:36:25.000000000 +0100
+++ bin/lwp-download    2004-12-10 21:12:41.136510344 +0100
@@ -91,7 +91,13 @@
   sub {
       unless($file) {
          my $res = $_[1];
-         unless ($argfile) {
+
+         my $directory;
+         if (defined $argfile && -d $argfile) {
+             ($directory, $argfile) = ($argfile, undef);
+         }
+
+         unless (defined $argfile && length $argfile) {
              # must find a suitable name to use.  First thing
              # to do is to look for the "Content-Disposition"
              # header defined by RFC1806.  This is also supported
@@ -130,6 +136,11 @@
                  }
              }
 
+             if (defined $directory) {
+                 require File::Spec;
+                 $file = File::Spec->catfile($directory, $file);
+             }
+
              # Check if the file is already present
              if (-f $file && -t) {
                  $shown = 1;
@@ -292,3 +303,5 @@
 {
     die "Usage: $progname [-a] <url> [<lpath>]\n";
 }
+
+# vi: ts=8 sw=4

Attachment: pgphuCwlWUCck.pgp
Description: PGP signature

Reply via email to