File-RsyncP
view release on metacpan or search on metacpan
FileList/FileList.pm view on Meta::CPAN
For example, to dump out each of hash you could do this:
use Data::Dumper;
my $count = $fileList->count;
for ( my $i = 0 ; $i < $count ; $i++ ) {
print("File $i is:\n");
print Dumper($fileList->get($i));
}
=head2 Encoding
The encode() function is used to build a file list in preparation for
encoding and sending a file list to a remote rsync. The encode()
function takes a hashref argument with the parameters for one file.
It should be called once for each file. The parameter names are the
same as those returned by get().
In this example the matching stat() values are shown:
$fileList->encode({
name => $filePath,
dev => $stat[0],
inode => $stat[1],
mode => $stat[2],
uid => $stat[4],
gid => $stat[5],
rdev => $stat[6],
size => $stat[7],
mtime => $stat[9],
});
It is not necessary to specify basename and dirname; these are extracted
from name. You only need to specify the parameters that match the
options given to new(). You can also specify sum and link as necessary.
To compute the encoded file list data the encodeData() function should
be called. It can be called every time encode() is called, or once
at the end of all the encode() calls. It returns the encoded data
that should be sent to the remote rsync:
$data = $fileList->encodeData;
It is recommended that encodeData() be called frequently to avoid the
need to allocate large internal buffers to hold the entire encoded
file list. Since encodeData() does not know when the last file
has been encoded, it is the caller's responsbility to add the
final null byte (eg: pack("C", 0)) to the data to indicate the
end of the file list data.
After all the file list entries are processed you should call clean():
$fileList->clean;
This ensures that each side (sender/receiver) has identical sorted
file lists.
=head2 Utility functions
The count() function returns the total number of files in the internal
file list (either decoded or encoded).
The fatalError() function returns true if a fatal error has occured
during file decoding. It should be called in the decode loop to
make sure no error has occured.
=head1 AUTHOR
File::RsyncP::FileList was written by Craig Barratt
<cbarratt@users.sourceforge.net> based on rsync 2.5.5.
Rsync was written by Andrew Tridgell <tridge@samba.org>
and Paul Mackerras. It is available under a GPL license.
See http://rsync.samba.org
=head1 LICENSE
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 the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License in the
LICENSE file along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
=head1 SEE ALSO
See L<http://perlrsync.sourceforge.net> for File::RsyncP's SourceForge
home page.
See L<File::RsyncP> and L<File::RsyncP::FileIO> for more
precise examples of using L<File::RsyncP::FileList>.
Also see BackupPC's lib/BackupPC/Xfer/RsyncFileIO.pm for other examples.
=cut
( run in 0.441 second using v1.01-cache-2.11-cpan-bbe5e583499 )