File Coverage

blib/lib/IO/File/fcntl.pm
Criterion Covered Total %
statement 12 27 44.4
branch 0 2 0.0
condition 0 2 0.0
subroutine 4 14 28.5
pod 7 8 87.5
total 23 53 43.4


line stmt bran cond sub pod time code
1             package IO::File::fcntl;
2 1     1   1763 use strict;
  1         2  
  1         47  
3 1     1   5 use base qw(IO::File::Lockable);
  1         2  
  1         93  
4 1     1   6 use vars qw($VERSION);
  1         1  
  1         40  
5 1     1   5 use Fcntl;
  1         2  
  1         882  
6             $VERSION = '0.31';
7             ######################################################################
8 0     0     sub DESTROY :method {shift->fcntl_un}
9 0     0 0   sub fcntl_ :method {CORE::fcntl($_[0],$_[1],$_[2])}
10             ##### override
11 0     0 1   sub lock_ex :method {shift->fcntl_ex(@_)}
12 0     0 1   sub lock_sh :method {shift->fcntl_sh(@_)}
13 0     0 1   sub lock_un :method {shift->fcntl_un(@_)}
14             ##### fcntl oop i/f
15             sub fcntl :method {
16 0     0 1   my $fh = shift;
17 0           my $lock = shift;
18 0   0       my $timeout = shift || 0;
19 0 0         return $fh unless($fh->opened);
20 0     0     return $fh->set_timeout(
21 0           $timeout => sub {fcntl_($fh,F_SETLKW,pack('ssx32',$lock,0));$fh}
22 0           );
23             }
24 0     0 1   sub fcntl_sh :method {shift->fcntl(F_RDLCK,@_)}
25 0     0 1   sub fcntl_ex :method {shift->fcntl(F_WRLCK,@_)}
26 0     0 1   sub fcntl_un :method {shift->fcntl(F_UNLCK,@_)}
27             1;
28             __END__