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