# Craig Barratt <cbarratt@users.sourceforge.net>
#
# COPYRIGHT
-# Copyright (C) 2001-2003 Craig Barratt
+# Copyright (C) 2001-2009 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
#
#========================================================================
#
-# Version 2.1.0_CVS, released 13 Mar 2004.
+# Version 3.2.0, released 31 Jul 2010.
#
# See http://backuppc.sourceforge.net.
#
use Carp;
use File::Path;
use File::Copy;
+use Encode;
#
# For compressed files we have a to careful about running out of memory
return $CompZlibOK;
}
+#
+# Request utf8 strings with readLine interface
+#
+sub utf8
+{
+ my($self, $mode) = @_;
+
+ $self->{utf8} = $mode;
+}
+
sub myDeflateInit
{
my $self = shift;
my $chr = substr($self->{dataIn}, 0, 1);
$self->{inflateStart} = 0;
- if ( $chr eq chr(0xd6) ) {
+ if ( $chr eq chr(0xd6) || $chr eq chr(0xd7) ) {
#
- # Flag 0xd6 means this is a compressed file with
+ # Flag 0xd6 or 0xd7 means this is a compressed file with
# appended md4 block checksums for rsync. Change
# the first byte back to 0x78 and proceed.
#
- ##print("Got 0xd6 block: normal\n");
+ ##print("Got 0xd6/0xd7 block: normal\n");
substr($self->{dataIn}, 0, 1) = chr(0x78);
} elsif ( $chr eq chr(0xb3) ) {
#
# the compressed file. Also seek the file so
# it is positioned at the 0xb3.
#
- seek($self->{fh}, -length($self->{dataIn}), 1);
+ sysseek($self->{fh}, -length($self->{dataIn}), 1);
$self->{eof} = 1;
$self->{dataIn} = "";
##print("Got 0xb3 block: considering eof\n");
if ( $str eq "" ) {
$str = $self->{readLineFrag};
$self->{readLineFrag} = "";
+ $str = decode_utf8($str) if ( $self->{utf8} );
return $str;
}
@{$self->{readLineBuf}} = split(/\n/, $self->{readLineFrag} . $str);
$self->{readLineFrag} = "";
}
}
- return shift(@{$self->{readLineBuf}}) . "\n";
+ $str = shift(@{$self->{readLineBuf}}) . "\n";
+ if ( $self->{utf8} ) {
+ my $strUtf8 = decode_utf8($str, 0);
+ $strUtf8 = $str if ( length($strUtf8) == 0 );
+ return $strUtf8;
+ }
+ return $str;
}
sub rewind