diff options
author | Oliver Tappe | 2007-05-13 19:22:27 +0200 |
---|---|---|
committer | Oliver Tappe | 2007-05-13 19:22:27 +0200 |
commit | 304e8df5559677ff57d39f9091f5b00925334c8b (patch) | |
tree | 26df61c0812551b7c47530df8bc1a7dff15f0492 /lib/OpenSLX/Utils.pm | |
parent | Make mkdxsinitrd able to follow symlinks in kernel module directory (diff) | |
download | core-304e8df5559677ff57d39f9091f5b00925334c8b.tar.gz core-304e8df5559677ff57d39f9091f5b00925334c8b.tar.xz core-304e8df5559677ff57d39f9091f5b00925334c8b.zip |
* 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
Diffstat (limited to 'lib/OpenSLX/Utils.pm')
-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 |