- my $destfd=writefile($file, $config{destdir}, undef, 1, 1);
- my $blksize = 16384;
- my ($len, $buf, $written);
- while ($len = sysread $srcfd, $buf, $blksize) {
- if (! defined $len) {
- next if $! =~ /^Interrupted/;
- error("failed to read $srcfile: $!");
- }
- my $offset = 0;
- while ($len) {
- defined($written = syswrite OUT, $buf, $len, $offset)
- or error("failed to write $file: $!");
- $len -= $written;
- $offset += $written;
+
+ if ($config{hardlink}) {
+ prep_writefile($file, $config{destdir});
+ unlink($config{destdir}."/".$file);
+ if (link($srcfile, $config{destdir}."/".$file)) {
+ return;