NAME

File::Copy::Vigilant - Copy and move files with verification and retries

VERSION

Version 1.0

SYNOPSIS

use File::Copy::Vigilant;

copy_vigilant( $source, $destination );
move_vigilant( $source, $destination );

DESCRIPTION

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.

EXPORT

A list of functions that can be exported. You can delete this section if you don't export anything, such as for a purely object-oriented module.

FUNCTIONS

copy_vigilant copy cp

Copies a file, with post-copy verification and optional retries.

copy_vigilant( $source, $destination, [ check => (checktype), ] [ retires => (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

"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 );

move_vigilant move mv

The syntax and behavior is exactly the same as copy_vigilant, except it perfoms an unlink as the last step.

This is terribly inefficient compared to File::Copy's move, which in most cases is a simple filesystem rename.

AUTHOR

Anthony Kilna, <anthony at kilna.com>

BUGS

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.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc File::Copy::Vigilant

You can also look for information at:

ACKNOWLEDGEMENTS

COPYRIGHT & LICENSE

Copyright 2009 Anthony Kilna, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 71:

Non-ASCII character seen before =encoding in 'success. '. Assuming CP1252