/[BackupPC]/trunk/bin/BackupPC_tarCreate
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/bin/BackupPC_tarCreate

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 315 by dpavlin, Wed Jun 22 19:12:42 2005 UTC revision 316 by dpavlin, Mon Jan 30 13:37:17 2006 UTC
# Line 51  Line 51 
51  #  #
52  #========================================================================  #========================================================================
53  #  #
54  # Version 2.1.0, released 20 Jun 2004.  # Version 2.1.2, released 5 Sep 2005.
55  #  #
56  # See http://backuppc.sourceforge.net.  # See http://backuppc.sourceforge.net.
57  #  #
# Line 227  sub archiveWrite Line 227  sub archiveWrite
227  #  #
228  sub archiveWriteHardLinks  sub archiveWriteHardLinks
229  {  {
230      my $fh = @_;      my($fh) = @_;
231      foreach my $hdr ( @HardLinks ) {      foreach my $hdr ( @HardLinks ) {
232          $hdr->{size} = 0;          $hdr->{size} = 0;
233            my $name = $hdr->{linkname};
234            $name =~ s{^\./}{/};
235            if ( defined($HardLinkExtraFiles{$name}) ) {
236                $hdr->{linkname} = $HardLinkExtraFiles{$name};
237            }
238          if ( defined($PathRemove)          if ( defined($PathRemove)
239                && substr($hdr->{linkname}, 0, length($PathRemove)+1)                && substr($hdr->{linkname}, 0, length($PathRemove)+1)
240                          eq ".$PathRemove" ) {                          eq ".$PathRemove" ) {
# Line 423  sub TarWriteFile Line 428  sub TarWriteFile
428          TarWriteFileInfo($fh, $hdr);          TarWriteFileInfo($fh, $hdr);
429          my($data, $size);          my($data, $size);
430          while ( $f->read(\$data, $BufSize) > 0 ) {          while ( $f->read(\$data, $BufSize) > 0 ) {
431                if ( $size + length($data) > $hdr->{size} ) {
432                    print(STDERR "Error: truncating $hdr->{fullPath} to"
433                               . " $hdr->{size} bytes\n");
434                    $data = substr($data, 0, $hdr->{size} - $size);
435                    $ErrorCnt++;
436                }
437              TarWrite($fh, \$data);              TarWrite($fh, \$data);
438              $size += length($data);              $size += length($data);
439          }          }
440          $f->close;          $f->close;
441            if ( $size != $hdr->{size} ) {
442                print(STDERR "Error: padding $hdr->{fullPath} to $hdr->{size}"
443                           . " bytes from $size bytes\n");
444                $ErrorCnt++;
445                while ( $size < $hdr->{size} ) {
446                    my $len = $hdr->{size} - $size;
447                    $len = $BufSize if ( $len > $BufSize );
448                    $data = "\0" x $len;
449                    TarWrite($fh, \$data);
450                    $size += $len;
451                }
452            }
453          TarWritePad($fh, $size);          TarWritePad($fh, $size);
454          $FileCnt++;          $FileCnt++;
455          $ByteCnt += $size;          $ByteCnt += $size;
# Line 456  sub TarWriteFile Line 479  sub TarWriteFile
479          my $done = 0;          my $done = 0;
480          my $name = $hdr->{linkname};          my $name = $hdr->{linkname};
481          $name =~ s{^\./}{/};          $name =~ s{^\./}{/};
482          if ( $HardLinkExtraFiles{$name} ) {          if ( defined($HardLinkExtraFiles{$name}) ) {
483              $done = 1;              $done = 1;
484          } else {          } else {
485              foreach my $arg ( @ARGV ) {              foreach my $arg ( @ARGV ) {
486                    $arg = "/" if ( $arg eq "." );
487                  $arg =~ s{^\./+}{/};                  $arg =~ s{^\./+}{/};
488                  $arg =~ s{/+$}{};                  $arg =~ s{/+$}{};
489                  $done = 1 if ( $name eq $arg || $name =~ /^\Q$arg\// );                  $done = 1 if ( $name eq $arg || $name =~ /^\Q$arg\// );
# Line 478  sub TarWriteFile Line 502  sub TarWriteFile
502              # routine, so that we save the hassle of dealing with              # routine, so that we save the hassle of dealing with
503              # mangling, merging and attributes.              # mangling, merging and attributes.
504              #              #
505              $HardLinkExtraFiles{$hdr->{linkname}} = 1;              my $name = $hdr->{linkname};
506              archiveWrite($fh, $hdr->{linkname}, $hdr->{name});              $name =~ s{^\./}{/};
507                $HardLinkExtraFiles{$name} = $hdr->{name};
508                archiveWrite($fh, $name, $hdr->{name});
509          }          }
510      } elsif ( $hdr->{type} == BPC_FTYPE_SYMLINK ) {      } elsif ( $hdr->{type} == BPC_FTYPE_SYMLINK ) {
511          #          #

Legend:
Removed from v.315  
changed lines
  Added in v.316

  ViewVC Help
Powered by ViewVC 1.1.26