X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=bin%2FBackupPC_compressPool;h=1c577c4669d26600fea2a724bbd3b8df30b612db;hp=e243837a85d760fdb898a2fab5580ddfeab5d41c;hb=e951f787a66c5bd9e9955c3f657a5b44289c0fe1;hpb=1ce7d1541ea1279aaa0a75c16986a3fd40b608ec diff --git a/bin/BackupPC_compressPool b/bin/BackupPC_compressPool index e243837..1c577c4 100755 --- a/bin/BackupPC_compressPool +++ b/bin/BackupPC_compressPool @@ -1,4 +1,4 @@ -#!/bin/perl -T +#!/bin/perl #============================================================= -*-perl-*- # # BackupPC_compressPool: Compress existing pool @@ -31,7 +31,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 @@ -49,19 +49,20 @@ # #======================================================================== # -# Version 1.5.0, released 2 Aug 2002. +# Version 2.1.0, released 20 Jun 2004. # # See http://backuppc.sourceforge.net. # #======================================================================== use strict; +no utf8; use File::Find; use File::Path; use Compress::Zlib; use Getopt::Std; -use lib "__INSTALLDIR__/lib"; +use lib "/usr/local/BackupPC/lib"; use BackupPC::Lib; use BackupPC::FileZIO; @@ -173,11 +174,12 @@ sub doCompress -Bufsize => 65536, -Level => $Compress, ); - if ( !open(FH, $TestMode ? "<$file" : "+<$file") ) { + if ( !open(FH, $TestMode ? "<" : "+<", $file) ) { print("Error: Can't open $file for read/write\n"); $Errors++; return; } + binmode(FH); while ( sysread(FH, $dataIn, $CompMaxWrite) > 0 ) { $flush = 0; $FileOrigSz += length($dataIn); @@ -196,12 +198,13 @@ sub doCompress } $dataOut .= $fragOut; if ( !$copy && length($dataOut) > $CompMaxWrite ) { - if ( !open(OUT, "+>$file.__z") ) { + if ( !open(OUT, "+>", "$file.__z") ) { print("Error: Can't open $file.__z for write\n"); $Errors++; close(FH); return; } + binmode(OUT); $copy = 1; } if ( $copy && $dataOut ne "" ) { @@ -237,13 +240,14 @@ sub doCompress my $newFile = cpoolFileName($file); if ( $TestMode ) { close(FH); - if ( !open(FH, ">$newFile") ) { + if ( !open(FH, ">", $newFile) ) { print("Error: Can't open $newFile for write\n"); $Errors++; close(FH); unlink("$file.__z"); return; } + binmode(FH); } if ( $copy ) { if ( !sysseek(OUT, 0, 0) ) { @@ -323,12 +327,13 @@ sub checkRead my($n, $nd, $r, $d, $d0); local(*FH); - if ( !open(FH, $file) ) { + if ( !open(FH, "<", $file) ) { print("can't open $file for check\n"); $Errors++; $f->close(); return; } + binmode(FH); #print("comparing $file to $cfile\n"); while ( 1 ) { $n = 1 + int(rand($CompMaxRead) + rand(100)); @@ -357,12 +362,13 @@ sub checkReadLine my($n, $nd, $r, $d, $d0); local(*FH); - if ( !open(FH, $file) ) { + if ( !open(FH, "<", $file) ) { print("can't open $file for check\n"); $Errors++; $f->close(); return; } + binmode(FH); while ( 1 ) { $d0 = ; $d = $f->readLine();