summaryrefslogtreecommitdiff
path: root/Master/tlpkg/TeXLive/TLUtils.pm
diff options
context:
space:
mode:
Diffstat (limited to 'Master/tlpkg/TeXLive/TLUtils.pm')
-rw-r--r--Master/tlpkg/TeXLive/TLUtils.pm21
1 files changed, 18 insertions, 3 deletions
diff --git a/Master/tlpkg/TeXLive/TLUtils.pm b/Master/tlpkg/TeXLive/TLUtils.pm
index c96fad10358..a35fd51fbbc 100644
--- a/Master/tlpkg/TeXLive/TLUtils.pm
+++ b/Master/tlpkg/TeXLive/TLUtils.pm
@@ -683,8 +683,10 @@ sub rmtree {
=pod
=item C<copy($file, $target_dir)>
+=item C<copy("-f", $file, $destfile)>
-Copy file C<$file> to directory C<$target_dir>. No external programs
+Copy file C<$file> to directory C<$target_dir>, or to the C<$destfile> in
+the second case. No external programs
are involved. Since we need C<sysopen()>, the Perl module C<Fcntl.pm>
is required. The time stamps are preserved and symlinks are created
on UNIX systems. On Windows, C<(-l $file)> will certainly never
@@ -700,6 +702,12 @@ Note that C<copy> will work with file:/ prefixes, too.
sub copy {
my $infile=shift;
+ my $filemode = 0;
+ if ($infile eq "-f") {
+ # second argument is a file!!!
+ $filemode = 1;
+ $infile = shift;
+ }
my $destdir=shift;
my $outfile;
my @stat;
@@ -710,11 +718,18 @@ sub copy {
my $dirmode=0755;
my $blocksize=2048;
- mkdirhier ("$destdir") unless -d "$destdir";
$infile =~ s!^file://*!/!i;
$filename=basename "$infile";
- $outfile="$destdir/$filename";
+ if ($filemode) {
+ # we actually got a destination file
+ $outfile = $destdir;
+ $destdir = dirname($outfile);
+ } else {
+ $outfile="$destdir/$filename";
+ }
+
+ mkdirhier ("$destdir") unless -d "$destdir";
if (-l "$infile") {
symlink readlink "$infile", "$destdir/$filename";