line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#line 1 |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package IO::File; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
#line 125 |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use 5.006_001; |
9
|
|
|
|
|
|
|
use strict; |
10
|
|
|
|
|
|
|
our($VERSION, @EXPORT, @EXPORT_OK, @ISA); |
11
|
|
|
|
|
|
|
use Carp; |
12
|
|
|
|
|
|
|
use Symbol; |
13
|
|
|
|
|
|
|
use SelectSaver; |
14
|
|
|
|
|
|
|
use IO::Seekable; |
15
|
|
|
|
|
|
|
use File::Spec; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
require Exporter; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
@ISA = qw(IO::Handle IO::Seekable Exporter); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
$VERSION = "1.14"; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
@EXPORT = @IO::Seekable::EXPORT; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
eval { |
26
|
|
|
|
|
|
|
# Make all Fcntl O_XXX constants available for importing |
27
|
|
|
|
|
|
|
require Fcntl; |
28
|
|
|
|
|
|
|
my @O = grep /^O_/, @Fcntl::EXPORT; |
29
|
|
|
|
|
|
|
Fcntl->import(@O); # first we import what we want to export |
30
|
|
|
|
|
|
|
push(@EXPORT, @O); |
31
|
|
|
|
|
|
|
}; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
################################################ |
34
|
|
|
|
|
|
|
## Constructor |
35
|
|
|
|
|
|
|
## |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub new { |
38
|
|
|
|
|
|
|
my $type = shift; |
39
|
|
|
|
|
|
|
my $class = ref($type) || $type || "IO::File"; |
40
|
|
|
|
|
|
|
@_ >= 0 && @_ <= 3 |
41
|
|
|
|
|
|
|
or croak "usage: new $class [FILENAME [,MODE [,PERMS]]]"; |
42
|
|
|
|
|
|
|
my $fh = $class->SUPER::new(); |
43
|
|
|
|
|
|
|
if (@_) { |
44
|
|
|
|
|
|
|
$fh->open(@_) |
45
|
|
|
|
|
|
|
or return undef; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
$fh; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
################################################ |
51
|
|
|
|
|
|
|
## Open |
52
|
|
|
|
|
|
|
## |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub open { |
55
|
|
|
|
|
|
|
@_ >= 2 && @_ <= 4 or croak 'usage: $fh->open(FILENAME [,MODE [,PERMS]])'; |
56
|
|
|
|
|
|
|
my ($fh, $file) = @_; |
57
|
|
|
|
|
|
|
if (@_ > 2) { |
58
|
|
|
|
|
|
|
my ($mode, $perms) = @_[2, 3]; |
59
|
|
|
|
|
|
|
if ($mode =~ /^\d+$/) { |
60
|
|
|
|
|
|
|
defined $perms or $perms = 0666; |
61
|
|
|
|
|
|
|
return sysopen($fh, $file, $mode, $perms); |
62
|
|
|
|
|
|
|
} elsif ($mode =~ /:/) { |
63
|
|
|
|
|
|
|
return open($fh, $mode, $file) if @_ == 3; |
64
|
|
|
|
|
|
|
croak 'usage: $fh->open(FILENAME, IOLAYERS)'; |
65
|
|
|
|
|
|
|
} else { |
66
|
|
|
|
|
|
|
return open($fh, IO::Handle::_open_mode_string($mode), $file); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
open($fh, $file); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
################################################ |
73
|
|
|
|
|
|
|
## Binmode |
74
|
|
|
|
|
|
|
## |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub binmode { |
77
|
|
|
|
|
|
|
( @_ == 1 or @_ == 2 ) or croak 'usage $fh->binmode([LAYER])'; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
my($fh, $layer) = @_; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
return binmode $$fh unless $layer; |
82
|
|
|
|
|
|
|
return binmode $$fh, $layer; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |