File::Copy::Vigilant - Copy and move files with verification and retries
use File::Copy::Vigilant; copy_vigilant( $source, $destination ); move_vigilant( $source, $destination );
A module for when your files absolutely, positively have to get there.
By default the copy and move functions will perform MD5 sums on the source and destination file to ensure that the destination file is exactly the same as the source file upon completion. If the copy or move fails for any reason it will attempt 2 retries by default.
Copies a file, with post-copy verification and optional retries.
copy_vigilant( $source, $destination, [ check => (checktype), ] [ retires => (number of retries), ] );
"checktype" is one of the following:
md5 - Get the MD5 sum of the source before copying, and compare it to the MD5 of the destination after copying (default) size - Get the size of the source before copying, and compare it to the size of the destination after copying compare - Perform a byte-for-byte comparison of the source and destination after copying none - Do not perform a check of the source to the destination
"number of retries" is one of the following:
0 - No retries are performed integer - The number of retries to perform (if a 1 is passed, then the copy will be attempted a maximum of 2 times). Must be a positive, whole number. 'infinite' - The string 'infinite' (and all other strings for that matter) will cause it to retry continuously until success
The default is 2 retries (or three attempts total).
If called in a scalar context, it returns 0 for failure or 1 for success. If called in a list context, the return value is a 1 or 0, followed by a list of error messages.
The 'cp' and 'copy' named versions the function are not exported by default, and you must specify them explicitly to use them:
use File::Copy::Vigilant qw(cp mv); cp( $source, $destination );
Or
use File::Copy::Vigilant qw(copy move); copy( $source, $destination );
The syntax for calling the move_vigilant function is exactly the same as copy_vigilant. If the source and destination are on the same device, it performs a rename. If the source and the destinaton are on different devices, a copy followed by a delete is performed.
'move' and 'mv' are not imported by default, you'll have to add them in the use syntax (see copy_vigilant for details).
Anthony Kilna, <anthony at kilna.com> - http://anthony.kilna.com
<anthony at kilna.com>
Please report any bugs or feature requests to bug-file-copy-vigilant at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=File-Copy-Vigilant. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-file-copy-vigilant at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc File::Copy::Vigilant
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=File-Copy-Vigilant
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/File-Copy-Vigilant
CPAN Ratings
http://cpanratings.perl.org/d/File-Copy-Vigilant
Search CPAN
http://search.cpan.org/dist/File-Copy-Vigilant
File::Copy - File::Copy::Reliable
Copyright 2016 Kilna Companies.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install File::Copy::Vigilant, copy and paste the appropriate command in to your terminal.
cpanm
cpanm File::Copy::Vigilant
CPAN shell
perl -MCPAN -e shell install File::Copy::Vigilant
For more information on module installation, please visit the detailed CPAN module installation guide.