From 65944ac0e1dc9460fd248f04194a34214506afa2 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 26 Jan 2009 13:30:36 +0100 Subject: checklinks: Create parent directories if neccessary --- bin/checklinks | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'bin') diff --git a/bin/checklinks b/bin/checklinks index ef96386..a2e21af 100755 --- a/bin/checklinks +++ b/bin/checklinks @@ -56,6 +56,7 @@ sub check_symlink { my $src = shift; my $dst = shift; + mkdirs($src); #if (not -e "$base/$dst") { # print_format('no dst!!', $src, $dst, 'red bold'); #} @@ -83,6 +84,7 @@ sub check_hardlink { my $src = shift; my $dst = shift; + mkdirs($src); if (not -e "$base/$dst") { print_format('no dst!!', $src, $dst, 'red bold'); } @@ -100,6 +102,18 @@ sub check_hardlink { } } +sub mkdirs { + my $source = shift; + my $path = $base; + $source =~ s/\/[^\/]+$//; + foreach(split(/\//, $source)) { + unless(-d "$path/$_") { + mkdir("$path/$_") or die("Can't create $path/$_: $!"); + } + $path .= $_; + } +} + sub print_format { my ($message, $src, $dst, $color) = @_; -- cgit v1.2.3