[PATCH] create non-existent output directory.

Jon Davies jon at hedgerows.org.uk
Tue Feb 8 11:09:16 EST 2011


sanitizing the output directory changed to use File::Spec->rel2abs
since abs_path is undef for non-existent directories - this allows the
code that creates the output directory to work
---

I've noticed that get_iplayer failed to download programmes if the
output directory doesn't exist, which isn't unreasonable, but on
looking at the code to see if I could change this I discovered that
it's supposed to try, but fails.

It turns out that to sanitize the output directory it uses abs_path(),
but this returns undef if the path doesn't exist.  Attached below is a
trivial patch to change this to use File::Spec->rel2abs(), which does
something similar, but successfully returns a path even if it doesn't
exist yet.

I suspect this will work cleanly on Win32 boxes, making the 'if'
wrapper around finding the path unnecessary, but I don't have
get_iplayer running on windows anywhere to test it.

Cheers
Jon



diff --git a/get_iplayer b/get_iplayer
index e13d3ea..162a2b3 100755
--- a/get_iplayer
+++ b/get_iplayer
@@ -54,6 +54,7 @@ use Fcntl;
 use File::Copy;
 use File::Path;
 use File::stat;
+use File::Spec;
 use Getopt::Long;
 use HTML::Entities;
 use HTTP::Cookies;
@@ -4560,7 +4561,7 @@ sub generate_filenames {

        # Determine direcotry and find it's absolute path
        if ( $^O !~ /^MSWin32$/ ) {
-               $prog->{dir} = abs_path( $opt->{
'output'.$prog->{type} } || $opt->{output} || $ENV{IPLAYER_OUTDIR} ||
'.' );
+               $prog->{dir} = File::Spec->rel2abs( $opt->{
'output'.$prog->{type} } || $opt->{output} || $ENV{IPLAYER_OUTDIR} ||
'.' );
        } else {
                $prog->{dir} = $opt->{ 'output'.$prog->{type} } ||
$opt->{output} || $ENV{IPLAYER_OUTDIR} || '.';
        }



More information about the get_iplayer mailing list