X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=bin%2FBackupPC_tarCreate;h=4366a274eb14b8435ce83f92bc616bb785e59cc4;hp=500bd8b4274765dd73dfc532d8557730f0f0b669;hb=fda25dc88a63ccac1c80efa2e4994bf0725ca9b7;hpb=c2b072c9ad558447fb73fedf0cad170214b7d80e diff --git a/bin/BackupPC_tarCreate b/bin/BackupPC_tarCreate index 500bd8b..4366a27 100755 --- a/bin/BackupPC_tarCreate +++ b/bin/BackupPC_tarCreate @@ -25,6 +25,8 @@ # -w writeBufSz write buffer size (default 1MB) # -e charset charset for encoding file names (default: value of # $Conf{ClientCharset} when backup was done) +# -l just print a file listing; don't generate an archive +# -L just print a detailed file listing; don't generate an archive # # The -h, -n and -s options specify which dump is used to generate # the tar archive. The -r and -p options can be used to relocate @@ -35,7 +37,7 @@ # Craig Barratt # # COPYRIGHT -# Copyright (C) 2001-2003 Craig Barratt +# Copyright (C) 2001-2007 Craig Barratt # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -53,7 +55,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0, released 25 Nov 2007. # # See http://backuppc.sourceforge.net. # @@ -74,7 +76,7 @@ die("BackupPC::Lib->new failed\n") if ( !(my $bpc = BackupPC::Lib->new) ); my %opts; -if ( !getopts("te:h:n:p:r:s:b:w:", \%opts) || @ARGV < 1 ) { +if ( !getopts("Llte:h:n:p:r:s:b:w:", \%opts) || @ARGV < 1 ) { print STDERR <{linkname}, "utf8", $Charset); } + if ( $opts{l} ) { + print($hdr->{name} . "\n"); + return; + } elsif ( $opts{L} ) { + my $owner = "$hdr->{uid}/$hdr->{gid}"; + + my $name = $hdr->{name}; + + if ( $hdr->{type} == BPC_FTYPE_SYMLINK + || $hdr->{type} == BPC_FTYPE_HARDLINK ) { + $name .= " -> $hdr->{linkname}"; + } + $name =~ s/\n/\\n/g; + + printf("%6o %9s %11.0f %s\n", + $hdr->{mode}, + $owner, + $hdr->{size}, + $name); + return; + } + # # Handle long link names (symbolic links) # @@ -432,6 +458,7 @@ sub TarWriteFile TarWriteFileInfo($fh, $hdr); $DirCnt++; } elsif ( $hdr->{type} == BPC_FTYPE_FILE ) { + my($data, $size); # # Regular file: write the header and file # @@ -442,31 +469,34 @@ sub TarWriteFile return; } TarWriteFileInfo($fh, $hdr); - my($data, $size); - while ( $f->read(\$data, $BufSize) > 0 ) { - if ( $size + length($data) > $hdr->{size} ) { - print(STDERR "Error: truncating $hdr->{fullPath} to" - . " $hdr->{size} bytes\n"); - $data = substr($data, 0, $hdr->{size} - $size); - $ErrorCnt++; - } - TarWrite($fh, \$data); - $size += length($data); - } - $f->close; - if ( $size != $hdr->{size} ) { - print(STDERR "Error: padding $hdr->{fullPath} to $hdr->{size}" - . " bytes from $size bytes\n"); - $ErrorCnt++; - while ( $size < $hdr->{size} ) { - my $len = $hdr->{size} - $size; - $len = $BufSize if ( $len > $BufSize ); - $data = "\0" x $len; + if ( $opts{l} || $opts{L} ) { + $size = $hdr->{size}; + } else { + while ( $f->read(\$data, $BufSize) > 0 ) { + if ( $size + length($data) > $hdr->{size} ) { + print(STDERR "Error: truncating $hdr->{fullPath} to" + . " $hdr->{size} bytes\n"); + $data = substr($data, 0, $hdr->{size} - $size); + $ErrorCnt++; + } TarWrite($fh, \$data); - $size += $len; + $size += length($data); + } + $f->close; + if ( $size != $hdr->{size} ) { + print(STDERR "Error: padding $hdr->{fullPath} to $hdr->{size}" + . " bytes from $size bytes\n"); + $ErrorCnt++; + while ( $size < $hdr->{size} ) { + my $len = $hdr->{size} - $size; + $len = $BufSize if ( $len > $BufSize ); + $data = "\0" x $len; + TarWrite($fh, \$data); + $size += $len; + } } + TarWritePad($fh, $size); } - TarWritePad($fh, $size); $FileCnt++; $ByteCnt += $size; } elsif ( $hdr->{type} == BPC_FTYPE_HARDLINK ) {