[patch] Allow a directory as lwp-download"s 2nd argument

[patch] Allow a directory as lwp-download"s 2nd argument

am 10.12.2004 21:34:00 von radek

--5I6of5zJg18YgZEa
Content-Type: multipart/mixed; boundary="DocE+STaALJfprDB"
Content-Disposition: inline


--DocE+STaALJfprDB
Content-Type: text/plain; charset=iso-8859-2
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

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.

--=20
Rados=B3aw Zieli=F1ski
[ GPG key: http://radek.karnet.pl/ ]

--DocE+STaALJfprDB
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="perl-libwww-lwp_download_dest_dir_support.patch"
Content-Transfer-Encoding: quoted-printable

--- 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 =3D $_[1];
- unless ($argfile) {
+
+ my $directory;
+ if (defined $argfile && -d $argfile) {
+ ($directory, $argfile) =3D ($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 @@
}
}
=20
+ if (defined $directory) {
+ require File::Spec;
+ $file =3D File::Spec->catfile($directory, $file);
+ }
+
# Check if the file is already present
if (-f $file && -t) {
$shown =3D 1;
@@ -292,3 +303,5 @@
{
die "Usage: $progname [-a] []\n";
}
+
+# vi: ts=3D8 sw=3D4

--DocE+STaALJfprDB--

--5I6of5zJg18YgZEa
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)

iD8DBQFBugg4vesRuUOywuARAlA1AKDBF+JiUoFENhJ/938AsMm1Fi2L+wCd FiJz
Z1D+siTdOewjT+zQg1JtNgw=
=oV2E
-----END PGP SIGNATURE-----

--5I6of5zJg18YgZEa--