diff options
Diffstat (limited to 'src/lib/OpenSLX/Utils.pm')
-rw-r--r-- | src/lib/OpenSLX/Utils.pm | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/lib/OpenSLX/Utils.pm b/src/lib/OpenSLX/Utils.pm index 6e722c00..c6d94842 100644 --- a/src/lib/OpenSLX/Utils.pm +++ b/src/lib/OpenSLX/Utils.pm @@ -24,6 +24,7 @@ $VERSION = 1.01; @EXPORT = qw( copyFile fakeFile linkFile + copyDir copyBinaryWithRequiredLibs slurpFile spitFile appendFile followLink @@ -95,6 +96,28 @@ sub copyFile return; } + +sub copyDir +{ + my $dirName = shift || croak 'need to pass in a fileName!'; + my $targetBase = shift || croak 'need to pass in target dir!'; + my $targetDirName = shift || ''; + + mkpath($targetBase) unless -d $targetBase; + my $target = "$targetBase/$targetDirName"; + vlog(2, _tr("copying '%s' to '%s'", $dirName, $target)); + if (system("cp -pr $dirName $target")) { + croak( + _tr( + "unable to copy file '%s' to dir '%s' (%s)", + $dirName, $target, $! + ) + ); + } + return; +} + + =item B<fakeFile($fullPath)> Creates the (empty) file I<$fullPath> unless it already exists. |