X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=bin%2FBackupPC_tarCreate;h=80ba75934680c5df592f99db6f778339724cdd7f;hp=3ba3bbcbeea12168ed94b61e8576129e37409f60;hb=a7690ea45972ea3db587bd94fa573edf20d75c91;hpb=0697368bbcef14908cd4684cf07744dc840464de diff --git a/bin/BackupPC_tarCreate b/bin/BackupPC_tarCreate index 3ba3bbc..80ba759 100755 --- a/bin/BackupPC_tarCreate +++ b/bin/BackupPC_tarCreate @@ -30,7 +30,7 @@ # Craig Barratt # # COPYRIGHT -# Copyright (C) 2001 Craig Barratt +# Copyright (C) 2001-2003 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 @@ -48,13 +48,14 @@ # #======================================================================== # -# Version 2.0.0_CVS, released 18 Jan 2003. +# Version 2.1.0_CVS, released 3 Jul 2003. # # See http://backuppc.sourceforge.net. # #======================================================================== use strict; +no utf8; use lib "/usr/local/BackupPC/lib"; use File::Path; use Getopt::Std; @@ -69,16 +70,15 @@ my $BinDir = $bpc->BinDir(); my %Conf = $bpc->Conf(); my %opts; -getopts("th:n:p:r:s:", \%opts); -if ( @ARGV < 1 ) { +if ( !getopts("th:n:p:r:s:", \%opts) || @ARGV < 1 ) { print(STDERR "usage: $0 [-t] [-h host] [-n dumpNum] [-s shareName]" . " [-r pathRemove] [-p pathAdd]" . " files/directories...\n"); exit(1); } -if ( $opts{h} !~ /^([\w\.-\s]+)$/ ) { +if ( $opts{h} !~ /^([\w\.\s-]+)$/ ) { print(STDERR "$0: bad host name '$opts{h}'\n"); exit(1); } @@ -136,6 +136,7 @@ my(%HardLinkExtraFiles, @HardLinks); # # Write out all the requested files/directories # +binmode(STDOUT); my $fh = *STDOUT; foreach my $dir ( @ARGV ) { archiveWrite($fh, $dir); @@ -227,13 +228,13 @@ sub TarWrite my $done = $WriteBufSz - length($WriteBuf); if ( syswrite($fh, $WriteBuf . substr($$dataRef, 0, $done)) != $WriteBufSz ) { - print(STDERR "Unable to write to output file\n"); + print(STDERR "Unable to write to output file ($!)\n"); exit(1); } while ( $done + $WriteBufSz <= length($$dataRef) ) { if ( syswrite($fh, substr($$dataRef, $done, $WriteBufSz)) != $WriteBufSz ) { - print(STDERR "Unable to write to output file\n"); + print(STDERR "Unable to write to output file ($!)\n"); exit(1); } $done += $WriteBufSz;