summaryrefslogtreecommitdiff
path: root/bin/checklinks
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2009-01-26 13:30:36 +0100
committerDaniel Friesel <derf@derf.homelinux.org>2009-01-26 13:30:36 +0100
commit65944ac0e1dc9460fd248f04194a34214506afa2 (patch)
treee95b283993b65d962a426579b7e71a6bd9a82280 /bin/checklinks
parentad34b3541014732f833d6c52f59f36c66bd32058 (diff)
checklinks: Create parent directories if neccessary
Diffstat (limited to 'bin/checklinks')
-rwxr-xr-xbin/checklinks14
1 files changed, 14 insertions, 0 deletions
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) = @_;