X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=lib%2FBackupPC%2FAttrib.pm;h=046cf870e85746ee887b235fa89fc76794b0c360;hp=f5c497e6b66c25182a5cd9efea927715c8c71587;hb=fda25dc88a63ccac1c80efa2e4994bf0725ca9b7;hpb=1ce7d1541ea1279aaa0a75c16986a3fd40b608ec diff --git a/lib/BackupPC/Attrib.pm b/lib/BackupPC/Attrib.pm index f5c497e..046cf87 100644 --- a/lib/BackupPC/Attrib.pm +++ b/lib/BackupPC/Attrib.pm @@ -12,7 +12,7 @@ # Craig Barratt # # COPYRIGHT -# Copyright (C) 2001 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 @@ -30,7 +30,7 @@ # #======================================================================== # -# Version 1.5.0, released 2 Aug 2002. +# Version 3.1.0, released 25 Nov 2007. # # See http://backuppc.sourceforge.net. # @@ -43,6 +43,7 @@ use strict; use Carp; use File::Path; use BackupPC::FileZIO; +use Encode qw/from_to/; require Exporter; use vars qw( @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS ); @@ -59,6 +60,7 @@ use constant BPC_FTYPE_DIR => 5; use constant BPC_FTYPE_FIFO => 6; use constant BPC_FTYPE_SOCKET => 8; use constant BPC_FTYPE_UNKNOWN => 9; +use constant BPC_FTYPE_DELETED => 10; my @FILE_TYPES = qw( BPC_FTYPE_FILE @@ -70,6 +72,7 @@ my @FILE_TYPES = qw( BPC_FTYPE_FIFO BPC_FTYPE_SOCKET BPC_FTYPE_UNKNOWN + BPC_FTYPE_DELETED ); # @@ -85,6 +88,8 @@ my @FileType2Text = ( "fifo", "?", "socket", + "?", + "deleted", ); # @@ -139,13 +144,18 @@ sub set { my($a, $fileName, $attrib) = @_; - $a->{files}{$fileName} = $attrib; + if ( !defined($attrib) ) { + delete($a->{files}{$fileName}); + } else { + $a->{files}{$fileName} = $attrib; + } } sub get { my($a, $fileName) = @_; - return $a->{files}{$fileName}; + return $a->{files}{$fileName} if ( defined($fileName) ); + return $a->{files}; } sub fileType2Text @@ -189,6 +199,8 @@ sub read my($data); $file = $a->fileName($dir, $file); + from_to($file, "utf8", $a->{charsetLegacy}) + if ( $a->{charsetLegacy} ne "" ); my $fd = BackupPC::FileZIO->open($file, 0, $a->{compress}); if ( !$fd ) { $a->{_errStr} = "Can't open $file"; @@ -231,6 +243,9 @@ sub read } } (my $fileName, $data) = unpack("a$len a*", $data); + + from_to($fileName, $a->{charsetLegacy}, "utf8") + if ( $a->{charsetLegacy} ne "" ); my $nFldsW = @FldsUnixW; my $nFldsN = @FldsUnixN; if ( length($data) < 5 * $nFldsW + 4 * $nFldsN ) {