diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/OpenSLX/Utils.pm | 19 |
1 files changed, 18 insertions, 1 deletions
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 |