summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorOliver Tappe2007-04-26 19:57:44 +0200
committerOliver Tappe2007-04-26 19:57:44 +0200
commit7b210b1641bc7b68c6e53b664e57baac7338b8f9 (patch)
tree91af114e512cc2ab98c6f084013f34f25dd362c5 /lib
parentMore cleanups ... (diff)
downloadcore-7b210b1641bc7b68c6e53b664e57baac7338b8f9.tar.gz
core-7b210b1641bc7b68c6e53b664e57baac7338b8f9.tar.xz
core-7b210b1641bc7b68c6e53b664e57baac7338b8f9.zip
* 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
Diffstat (limited to 'lib')
-rw-r--r--lib/OpenSLX/Utils.pm20
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, $!);
}
}