| 1 | # Copyrights 2011-2020 by [Mark Overmeer <markov@cpan.org>]. | ||||||||||||||||||||||||||||
| 2 | # For other contributors see ChangeLog. | ||||||||||||||||||||||||||||
| 3 | # See the manual pages for details on the licensing terms. | ||||||||||||||||||||||||||||
| 4 | # Pod stripped from pm file by OODoc 2.02. | ||||||||||||||||||||||||||||
| 5 | # This code is part of distribution IOMux. Meta-POD processed with OODoc | ||||||||||||||||||||||||||||
| 6 | # into POD and HTML manual-pages. See README.md | ||||||||||||||||||||||||||||
| 7 | # Copyright Mark Overmeer. Licensed under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | package IOMux::File::Read; | ||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use vars '$VERSION'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 3 | $VERSION = '1.01'; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 3 | ▶ | use base 'IOMux::Handler::Read'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 3 | ▶ | use Log::Report 'iomux'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 3 | ▶ | use Fcntl; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | 3 | ▶ | use File::Basename 'basename'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | sub init($) | ||||||||||||||||||||||||||||
| 24 | 4 | ▶ | { my ($self, $args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
init: called CC=8 SCAR=23.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | my $file = $args->{file} | ||||||||||||||||||||||||||||
| 27 | 4 | ▶ | or error __x"no file to open specified in {pkg}", pkg => __PACKAGE__; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 4 | my $flags = $args->{modeflags}; | |||||||||||||||||||||||||||
| 30 | 4 | ▶ | unless(ref $file || defined $flags) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $file or defined $flags
MC/DC0%0/2
ref $file or defined $flags
ref $file
defined $flags
Truth table33%1/3
A or B
A= ref $fileB= defined $flags
| |||||||||||||||||||||||||||||
| 31 | 4 | { $flags = O_RDONLY|O_NONBLOCK; | |||||||||||||||||||||||||||
| 32 | 4 | ▶ | $flags |= O_EXCL if $args->{exclusive}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 4 | my $fh; | |||||||||||||||||||||||||||
| 36 | 4 | ▶ | if(ref $file) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | 0 | { $fh = $file; | |||||||||||||||||||||||||||
| 38 | 0 | ▶ | $self->{IMFR_mode} = $args->{mode} || '<'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args->{'mode'} || '<'
MC/DC0%0/1
$args->{'mode'} || '<'
$args->{'mode'}
Truth table0%0/2
A
A= $args->{'mode'}
| |||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | else | ||||||||||||||||||||||||||||
| 41 | 4 | ▶ | { sysopen $fh, $file, $flags | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | or fault __x"cannot open file {fn} for {pkg}" | ||||||||||||||||||||||||||||
| 43 | , fn => $file, pkg => __PACKAGE__; | ||||||||||||||||||||||||||||
| 44 | 4 | $self->{IMFR_mode} = $flags; | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | 4 | $args->{name} = '<'.(basename $file); | |||||||||||||||||||||||||||
| 47 | 4 | $args->{fh} = $fh; | |||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 4 | $self->SUPER::init($args); | |||||||||||||||||||||||||||
| 50 | 4 | $self; | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | sub open($$@) | ||||||||||||||||||||||||||||
| 55 | 2 | ▶ | { my ($class, $mode, $file, %args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
open: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 56 | 2 | $class->new(file => $file, mode => $mode, %args); | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | #------------------- | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 0 | ▶ | sub mode() {shift->{IMFR_mode}} | ||||||||||||||||||||||||||
|
Subroutine
mode: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 3 | 1; | |||||||||||||||||||||||||||