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


File-Copy-Vigilant documentation  | view source Contained in the File-Copy-Vigilant distribution.

Index


NAME

Top

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

VERSION

Top

Version 1.01

SYNOPSIS

Top

    use File::Copy::Vigilant;

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

DESCRIPTION

Top

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.

FUNCTIONS

Top

copy_vigilant, copy, cp

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

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.

'move' and 'mv' are not imported by default, you'll have to add them in the use syntax (see copy_vigilant for details).

AUTHOR

Top

Anthony Kilna, <anthony at kilna.com>

BUGS

Top

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

Top

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

SEE ALSO

Top

File::Copy - File::Copy::Reliable

COPYRIGHT & LICENSE

Top


File-Copy-Vigilant documentation  | view source Contained in the File-Copy-Vigilant distribution.