| 1 | package App::optex::Tmpfile; | ||||||||||
| 2 | |||||||||||
| 3 | # DEPRECATED: superseded by Command::Run::Tmpfile (use new(raw => 1) for | ||||||||||
| 4 | # byte-transparent behavior). Kept only for backward compatibility with | ||||||||||
| 5 | # external consumers (App::optex::git, ::msdoc, ::textconv) that still | ||||||||||
| 6 | # "use App::optex::Tmpfile". Remove once those have migrated to | ||||||||||
| 7 | # Command::Run::Tmpfile and been released. | ||||||||||
| 8 | |||||||||||
| 9 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 1 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 1 | ▶ | use Fcntl; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 1 | ▶ | use IO::File; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 1 | ▶ | use IO::Handle; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | |||||||||||
| 16 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||
| 17 | 0 | my $class = shift; | |||||||||
| 18 | 0 | ▶ | my $fh = new_tmpfile IO::File or die "new_tmpfile: $!\n"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 19 | 0 | ▶ | $fh->fcntl(F_SETFD, 0) or die "fcntl F_SETFD: $!\n"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | 0 | bless { FH => $fh }, $class; | |||||||||
| 21 | } | ||||||||||
| 22 | |||||||||||
| 23 | 0 | ▶ | sub write { | ||||||||
|
Subroutine
write: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 24 | 0 | my $obj = shift; | |||||||||
| 25 | 0 | my $fh = $obj->fh; | |||||||||
| 26 | 0 | ▶ | if (@_) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | 0 | my $data = join '', @_; | |||||||||
| 28 | 0 | $fh->print($data); | |||||||||
| 29 | } | ||||||||||
| 30 | 0 | $obj; | |||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | 0 | ▶ | sub flush { | ||||||||
|
Subroutine
flush: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 34 | 0 | my $obj = shift; | |||||||||
| 35 | 0 | $obj->fh->flush; | |||||||||
| 36 | 0 | $obj; | |||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | 0 | ▶ | sub rewind { | ||||||||
|
Subroutine
rewind: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 40 | 0 | my $obj = shift; | |||||||||
| 41 | 0 | ▶ | $obj->fh->seek(0, 0) or die; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | 0 | $obj; | |||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | 0 | ▶ | sub reset { | ||||||||
|
Subroutine
reset: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 46 | 0 | my $obj = shift; | |||||||||
| 47 | 0 | $obj->rewind; | |||||||||
| 48 | 0 | $obj->fh->truncate(0); | |||||||||
| 49 | 0 | $obj; | |||||||||
| 50 | } | ||||||||||
| 51 | |||||||||||
| 52 | 0 | ▶ | sub fh { | ||||||||
|
Subroutine
fh: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 53 | 0 | my $obj = shift; | |||||||||
| 54 | 0 | $obj->{FH}; | |||||||||
| 55 | } | ||||||||||
| 56 | |||||||||||
| 57 | 0 | ▶ | sub fd { | ||||||||
|
Subroutine
fd: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 58 | 0 | my $obj = shift; | |||||||||
| 59 | 0 | $obj->fh->fileno; | |||||||||
| 60 | } | ||||||||||
| 61 | |||||||||||
| 62 | 0 | ▶ | sub path { | ||||||||
|
Subroutine
path: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 63 | 0 | my $obj = shift; | |||||||||
| 64 | 0 | sprintf "/dev/fd/%d", $obj->fd; | |||||||||
| 65 | } | ||||||||||
| 66 | |||||||||||
| 67 | 1 | 1; | |||||||||