… | |
… | |
191 | use common::sense; |
191 | use common::sense; |
192 | |
192 | |
193 | use base 'Exporter'; |
193 | use base 'Exporter'; |
194 | |
194 | |
195 | BEGIN { |
195 | BEGIN { |
196 | our $VERSION = '3.3'; |
196 | our $VERSION = '3.31'; |
197 | |
197 | |
198 | our @AIO_REQ = qw(aio_sendfile aio_read aio_write aio_open aio_close |
198 | our @AIO_REQ = qw(aio_sendfile aio_read aio_write aio_open aio_close |
199 | aio_stat aio_lstat aio_unlink aio_rmdir aio_readdir aio_readdirx |
199 | aio_stat aio_lstat aio_unlink aio_rmdir aio_readdir aio_readdirx |
200 | aio_scandir aio_symlink aio_readlink aio_sync aio_fsync |
200 | aio_scandir aio_symlink aio_readlink aio_sync aio_fsync |
201 | aio_fdatasync aio_sync_file_range aio_pathsync aio_readahead |
201 | aio_fdatasync aio_sync_file_range aio_pathsync aio_readahead |
… | |
… | |
634 | |
634 | |
635 | =item aio_copy $srcpath, $dstpath, $callback->($status) |
635 | =item aio_copy $srcpath, $dstpath, $callback->($status) |
636 | |
636 | |
637 | Try to copy the I<file> (directories not supported as either source or |
637 | Try to copy the I<file> (directories not supported as either source or |
638 | destination) from C<$srcpath> to C<$dstpath> and call the callback with |
638 | destination) from C<$srcpath> to C<$dstpath> and call the callback with |
639 | a status of C<0> (error) or C<-1> (ok). |
639 | a status of C<0> (ok) or C<-1> (error, see C<$!>). |
640 | |
640 | |
641 | This is a composite request that creates the destination file with |
641 | This is a composite request that creates the destination file with |
642 | mode 0200 and copies the contents of the source file into it using |
642 | mode 0200 and copies the contents of the source file into it using |
643 | C<aio_sendfile>, followed by restoring atime, mtime, access mode and |
643 | C<aio_sendfile>, followed by restoring atime, mtime, access mode and |
644 | uid/gid, in that order. |
644 | uid/gid, in that order. |
… | |
… | |
656 | my $grp = aio_group $cb; |
656 | my $grp = aio_group $cb; |
657 | |
657 | |
658 | aioreq_pri $pri; |
658 | aioreq_pri $pri; |
659 | add $grp aio_open $src, O_RDONLY, 0, sub { |
659 | add $grp aio_open $src, O_RDONLY, 0, sub { |
660 | if (my $src_fh = $_[0]) { |
660 | if (my $src_fh = $_[0]) { |
661 | my @stat = stat $src_fh; # hmm, might bock over nfs? |
661 | my @stat = stat $src_fh; # hmm, might block over nfs? |
662 | |
662 | |
663 | aioreq_pri $pri; |
663 | aioreq_pri $pri; |
664 | add $grp aio_open $dst, O_CREAT | O_WRONLY | O_TRUNC, 0200, sub { |
664 | add $grp aio_open $dst, O_CREAT | O_WRONLY | O_TRUNC, 0200, sub { |
665 | if (my $dst_fh = $_[0]) { |
665 | if (my $dst_fh = $_[0]) { |
666 | aioreq_pri $pri; |
666 | aioreq_pri $pri; |
… | |
… | |
713 | |
713 | |
714 | =item aio_move $srcpath, $dstpath, $callback->($status) |
714 | =item aio_move $srcpath, $dstpath, $callback->($status) |
715 | |
715 | |
716 | Try to move the I<file> (directories not supported as either source or |
716 | Try to move the I<file> (directories not supported as either source or |
717 | destination) from C<$srcpath> to C<$dstpath> and call the callback with |
717 | destination) from C<$srcpath> to C<$dstpath> and call the callback with |
718 | the status C<0> (error) or C<-1> (ok). |
718 | a status of C<0> (ok) or C<-1> (error, see C<$!>). |
719 | |
719 | |
720 | This is a composite request that tries to rename(2) the file first; if |
720 | This is a composite request that tries to rename(2) the file first; if |
721 | rename fails with C<EXDEV>, it copies the file with C<aio_copy> and, if |
721 | rename fails with C<EXDEV>, it copies the file with C<aio_copy> and, if |
722 | that is successful, unlinks the C<$srcpath>. |
722 | that is successful, unlinks the C<$srcpath>. |
723 | |
723 | |