… | |
… | |
67 | use base 'Exporter'; |
67 | use base 'Exporter'; |
68 | |
68 | |
69 | use Fcntl (); |
69 | use Fcntl (); |
70 | |
70 | |
71 | BEGIN { |
71 | BEGIN { |
72 | $VERSION = '1.7'; |
72 | $VERSION = '1.73'; |
73 | |
73 | |
74 | @EXPORT = qw(aio_sendfile aio_read aio_write aio_open aio_close aio_stat |
74 | @EXPORT = qw(aio_sendfile aio_read aio_write aio_open aio_close aio_stat |
75 | aio_lstat aio_unlink aio_rmdir aio_readdir aio_scandir aio_symlink |
75 | aio_lstat aio_unlink aio_rmdir aio_readdir aio_scandir aio_symlink |
76 | aio_fsync aio_fdatasync aio_readahead); |
76 | aio_fsync aio_fdatasync aio_readahead); |
77 | @EXPORT_OK = qw(poll_fileno poll_cb min_parallel max_parallel |
77 | @EXPORT_OK = qw(poll_fileno poll_cb min_parallel max_parallel |
… | |
… | |
237 | =item aio_rmdir $pathname, $callback->($status) |
237 | =item aio_rmdir $pathname, $callback->($status) |
238 | |
238 | |
239 | Asynchronously rmdir (delete) a directory and call the callback with the |
239 | Asynchronously rmdir (delete) a directory and call the callback with the |
240 | result code. |
240 | result code. |
241 | |
241 | |
242 | =item aio_readdir $pathname $callback->($entries) |
242 | =item aio_readdir $pathname, $callback->($entries) |
243 | |
243 | |
244 | Unlike the POSIX call of the same name, C<aio_readdir> reads an entire |
244 | Unlike the POSIX call of the same name, C<aio_readdir> reads an entire |
245 | directory (i.e. opendir + readdir + closedir). The entries will not be |
245 | directory (i.e. opendir + readdir + closedir). The entries will not be |
246 | sorted, and will B<NOT> include the C<.> and C<..> entries. |
246 | sorted, and will B<NOT> include the C<.> and C<..> entries. |
247 | |
247 | |
… | |
… | |
282 | |
282 | |
283 | Then entires will be sorted into likely directories (everything without a |
283 | Then entires will be sorted into likely directories (everything without a |
284 | non-initial dot) and likely non-directories (everything else). Then every |
284 | non-initial dot) and likely non-directories (everything else). Then every |
285 | entry + C</.> will be C<stat>'ed, likely directories first. This is often |
285 | entry + C</.> will be C<stat>'ed, likely directories first. This is often |
286 | faster because filesystems might detect the type of the entry without |
286 | faster because filesystems might detect the type of the entry without |
287 | reading the inode data (e.g. ext2s filetype feature). If that succeeds, |
287 | reading the inode data (e.g. ext2fs filetype feature). If that succeeds, |
288 | it assumes that the entry is a directory or a symlink to directory (which |
288 | it assumes that the entry is a directory or a symlink to directory (which |
289 | will be checked seperately). |
289 | will be checked seperately). |
290 | |
290 | |
291 | If the known number of directories has been reached, the rest of the |
291 | If the known number of directories has been reached, the rest of the |
292 | entries is assumed to be non-directories. |
292 | entries is assumed to be non-directories. |
… | |
… | |
298 | |
298 | |
299 | $maxreq = 8 if $maxreq <= 0; |
299 | $maxreq = 8 if $maxreq <= 0; |
300 | |
300 | |
301 | # stat once |
301 | # stat once |
302 | aio_stat $path, sub { |
302 | aio_stat $path, sub { |
303 | $cb->() if $_[0]; |
303 | return $cb->() if $_[0]; |
304 | my $hash1 = join ":", (stat _)[0,1,3,7,9]; |
304 | my $hash1 = join ":", (stat _)[0,1,3,7,9]; |
305 | |
305 | |
306 | # read the directory entries |
306 | # read the directory entries |
307 | aio_readdir $path, sub { |
307 | aio_readdir $path, sub { |
308 | my $entries = shift |
308 | my $entries = shift |
… | |
… | |
345 | } |
345 | } |
346 | } elsif (!$nreq) { |
346 | } elsif (!$nreq) { |
347 | # finished |
347 | # finished |
348 | undef $statcb; |
348 | undef $statcb; |
349 | undef $schedcb; |
349 | undef $schedcb; |
350 | $cb->(\@dirs, \@nondirs); |
350 | $cb->(\@dirs, \@nondirs) if $cb; |
351 | undef $cb; |
351 | undef $cb; |
352 | } |
352 | } |
353 | }; |
353 | }; |
354 | $statcb = sub { |
354 | $statcb = sub { |
355 | my ($status, $entry) = @_; |
355 | my ($status, $entry) = @_; |