diff options
-rw-r--r-- | lib/OpenSLX/Utils.pm | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/lib/OpenSLX/Utils.pm b/lib/OpenSLX/Utils.pm index 1c78f802..ef4c1cac 100644 --- a/lib/OpenSLX/Utils.pm +++ b/lib/OpenSLX/Utils.pm @@ -35,17 +35,15 @@ use OpenSLX::Basics; sub copyFile { my $fileName = shift; - my $dirName = shift; - - my $baseName = basename($fileName); - my $targetName = "$dirName/$baseName"; - if (!-e $targetName) { - my $targetDir = dirname($targetName); - system("mkdir -p $targetDir") unless -d $targetDir; - if (system("cp -p $fileName $targetDir/")) { - die _tr("unable to copy file '%s' to dir '%s' (%s)", - $fileName, $targetDir, $!); - } + my $targetDir = shift; + my $targetFileName = shift || ''; + + system("mkdir -p $targetDir") unless -d $targetDir; + my $target = "$targetDir/$targetFileName"; + vlog 2, _tr("copying '%s' to '%s'", $fileName, $target); + if (system("cp -p $fileName $target")) { + die _tr("unable to copy file '%s' to dir '%s' (%s)", + $fileName, $target, $!); } } |