From 7b210b1641bc7b68c6e53b664e57baac7338b8f9 Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Thu, 26 Apr 2007 17:57:44 +0000 Subject: * added support to copyFile for passing in the name of the target file (to rename during copy) git-svn-id: http://svn.openslx.org/svn/openslx/trunk@928 95ad53e4-c205-0410-b2fa-d234c58c8868 --- lib/OpenSLX/Utils.pm | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'lib') 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, $!); } } -- cgit v1.2.3-55-g7522