| 1 | package Nagios::Passive::Role::Tempfile; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | ▶ | use Any::Moose 'Role'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use File::Temp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 2 | ▶ | use Fcntl qw/:DEFAULT :flock/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 2 | requires 'checkresults_dir'; | |||||||||
| 8 | |||||||||||
| 9 | 2 | has 'tempfile' => ( is => 'ro', isa => 'File::Temp', lazy_build => 1); | |||||||||
| 10 | |||||||||||
| 11 | sub _build_tempfile { | ||||||||||
| 12 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
_build_tempfile: not called CC=1 SCAR=6.9
| |||||||||||
| 13 | 0 | my $fh = File::Temp->new( | |||||||||
| 14 | TEMPLATE => "cXXXXXX", | ||||||||||
| 15 | DIR => $self->checkresults_dir, | ||||||||||
| 16 | ); | ||||||||||
| 17 | 0 | $fh->unlink_on_destroy(0); | |||||||||
| 18 | 0 | return $fh; | |||||||||
| 19 | } | ||||||||||
| 20 | |||||||||||
| 21 | sub _touch_file { | ||||||||||
| 22 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
_touch_file: not called CC=3 SCAR=24.8
| |||||||||||
| 23 | 0 | my $fh = $self->tempfile; | |||||||||
| 24 | 0 | my $file = $fh->filename.".ok"; | |||||||||
| 25 | 0 | ▶ | sysopen my $t,$file,O_WRONLY|O_CREAT|O_NONBLOCK|O_NOCTTY | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | or croak("Can't create $file : $!"); | ||||||||||
| 27 | 0 | ▶ | close $t or croak("Can't close $file : $!"); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | 0 | return; | |||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | 2 | 1; | |||||||||
| 32 | |||||||||||
| 33 | __END__ | ||||||||||