File Coverage

blib/lib/Patro/Mony.pm
Criterion Covered Total %
statement 54 64 84.3
branch 23 28 82.1
condition 2 3 66.6
subroutine 15 17 88.2
pod n/a
total 94 112 83.9


line stmt bran cond sub pod time code
1             package Patro::Mony;
2 69     69   395 use strict;
  69         117  
  69         1667  
3 69     69   318 use warnings;
  69         117  
  69         55287  
4              
5             # Repository for functions the Patro distribution
6             # will assign in the CORE::GLOBAL namespace.
7              
8             if (defined &CORE::read) {
9             *CORE::GLOBAL::read = sub (*\$$;$) {
10 4     4   868 $Patro::read_sysread_flag = 'read';
11 4         61 goto &CORE::read;
12             };
13             *CORE::GLOBAL::sysread = sub (*\$$;$) {
14 2     2   547 $Patro::read_sysread_flag = 'sysread';
15 2         23 goto &CORE::sysread;
16             };
17             } else {
18             $Patro::read_sysread_flag = 'read?';
19             }
20              
21             *CORE::GLOBAL::truncate = \&_truncate;
22             *CORE::GLOBAL::stat = \&_stat;
23             *CORE::GLOBAL::flock = \&_flock;
24             *CORE::GLOBAL::fcntl = \&_fcntl;
25              
26             *CORE::GLOBAL::sysopen = \&_sysopen;
27             *CORE::GLOBAL::lstat = \&_lstat;
28              
29             *CORE::GLOBAL::opendir = \&_opendir;
30             *CORE::GLOBAL::closedir = \&_closedir;
31             *CORE::GLOBAL::readdir = \&_readdir;
32             *CORE::GLOBAL::seekdir = \&_seekdir;
33             *CORE::GLOBAL::telldir = \&_telldir;
34             *CORE::GLOBAL::rewinddir = \&_rewinddir;
35             *CORE::GLOBAL::chdir = \&_chdir;
36              
37             sub _truncate {
38 2     2   267 my ($fh,$len) = @_;
39 2 100       9 if (CORE::ref($fh) eq 'Patro::N5') {
40 1         3 return $fh->_tied->__('TRUNCATE',1,$len);
41             } else {
42 1         54 return CORE::truncate($fh,$len);
43             }
44             }
45              
46             sub _fcntl {
47 0     0   0 my ($fh,$func,$scalar) = @_;
48 0 0       0 if (CORE::ref($fh) eq 'Patro::N5') {
49 0         0 return $fh->_tied->__('FCNTL',1,$func,$scalar);
50             } else {
51 0         0 return CORE::fcntl($fh,$func,$scalar);
52             }
53             }
54              
55             sub _stat {
56 4     4   796 my ($fh) = @_;
57 4 100       17 if (CORE::ref($fh) eq 'Patro::N5') {
58 2         4 my $context = defined(wantarray) + wantarray + 0;
59 2         6 return $fh->_tied->__('STAT',$context);
60             } else {
61 2         31 return CORE::stat $fh;
62             }
63             }
64              
65             sub _flock {
66 76     76   1653 my ($fh,$op) = @_;
67 76 100       351 if (CORE::ref($fh) eq 'Patro::N5') {
68 4         43 return $fh->_tied->__('FLOCK',1,$op);
69             } else {
70 72         827 return CORE::flock($fh,$op);
71             }
72             }
73              
74             sub _sysopen {
75 6     6   1296 my ($fh,$fname,$mode,$perm) = @_;
76 6 100       17 if (CORE::ref($fh) eq 'Patro::N5') {
    50          
77 3         8 return $fh->_tied->__('SYSOPEN',1,$fname,$mode,$perm);
78             } elsif (defined ($perm)) {
79 0         0 return CORE::sysopen($fh,$fname,$mode,$perm);
80             } else {
81 3         161 return CORE::sysopen($fh,$fname,$mode);
82             }
83             }
84              
85             sub _lstat (;*) {
86 0     0   0 my ($fh) = @_;
87 0 0       0 if (CORE::ref($fh) eq 'Patro::N5') {
88 0         0 my $context = defined(wantarray) + wantarray + 0;
89 0         0 return $fh->_tied->__('LSTAT',$context);
90             }
91 0         0 return CORE::lstat $fh;
92             }
93              
94             sub _opendir (*$) {
95 5 100   5   1568 if (CORE::ref($_[0]) eq 'Patro::N5') {
96 1         9 return $_[0]->_tied->__('OPENDIR',1,$_[1]);
97             }
98 4         138 return CORE::opendir($_[0],$_[1]);
99             }
100              
101             sub _closedir (*) {
102 2     2   407 my ($fh) = @_;
103 2 100       14 if (CORE::ref($fh) eq 'Patro::N5') {
104 1         4 return $fh->_tied->__('CLOSEDIR',1);
105             }
106 1         25 return CORE::closedir($fh);
107             }
108              
109             sub _readdir (*) {
110 6     6   1287 my ($fh) = @_;
111 6 100       22 if (CORE::ref($fh) eq 'Patro::N5') {
112 3         10 return $fh->_tied->__('READDIR',undef);
113             }
114 3         90 return CORE::readdir($fh);
115             }
116              
117             sub _seekdir (*$) {
118 2     2   877 my ($fh,$pos) = @_;
119 2 100       9 if (CORE::ref($fh) eq 'Patro::N5') {
120 1         5 return $fh->_tied->__('SEEKDIR',1,$pos);
121             }
122 1         19 return CORE::seekdir($fh,$pos);
123             }
124              
125             sub _telldir (*) {
126 6     6   792 my ($fh) = @_;
127 6 100       18 if (CORE::ref($fh) eq 'Patro::N5') {
128 3         9 return $fh->_tied->__('TELLDIR',1);
129             }
130 3         15 return CORE::telldir($fh);
131             }
132              
133             sub _rewinddir (*) {
134 2     2   461 my ($fh) = @_;
135 2 100       11 if (CORE::ref($fh) eq 'Patro::N5') {
136 1         91 return $fh->_tied->__('REWINDDIR',1);
137             }
138 1         11 return CORE::rewinddir($fh);
139             }
140              
141             sub _chdir (;$) {
142 2     2   426 my ($fh) = @_;
143 2 100 66     21 if ($fh && CORE::ref($fh) eq 'Patro::N5') {
144 1         4 return $fh->_tied->__('CHDIR',1);
145             }
146 1         14 return CORE::chdir($fh);
147             }
148              
149             1;
150