From 304e8df5559677ff57d39f9091f5b00925334c8b Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Sun, 13 May 2007 17:22:27 +0000 Subject: * added utility function followLink() and made use of it * reworked search for required kernel modules to be able to return the matching paths to the caller (not currently used though) git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1069 95ad53e4-c205-0410-b2fa-d234c58c8868 --- lib/OpenSLX/Utils.pm | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/OpenSLX/Utils.pm b/lib/OpenSLX/Utils.pm index d86167a2..779640d5 100644 --- a/lib/OpenSLX/Utils.pm +++ b/lib/OpenSLX/Utils.pm @@ -21,7 +21,7 @@ $VERSION = 1.01; @ISA = qw(Exporter); @EXPORT = qw( - ©File &fakeFile &linkFile &slurpFile + ©File &fakeFile &linkFile &slurpFile &followLink ); ################################################################################ @@ -86,4 +86,21 @@ sub slurpFile return $text; } +sub followLink +{ + my $path = shift; + my $prefixedPath = shift || ''; + + my $target; + while (-l "$path") { + $target = readlink "$path"; + if (substr($target, 1, 1) eq '/') { + $path = "$prefixedPath/$target"; + } else { + $path = $prefixedPath.dirname($path).'/'.$target; + } + } + return $path; +} + 1; \ No newline at end of file -- cgit v1.2.3-55-g7522