File Coverage

blib/lib/Linux/TempFile.pm
Criterion Covered Total %
statement 20 26 76.9
branch 1 4 25.0
condition n/a
subroutine 7 8 87.5
pod 2 2 100.0
total 30 40 75.0


line stmt bran cond sub pod time code
1             package Linux::TempFile;
2 2     2   21216 use 5.008001;
  2         6  
3 2     2   12 use strict;
  2         2  
  2         44  
4 2     2   17 use warnings;
  2         4  
  2         57  
5 2     2   10 use base 'IO::Handle';
  2         3  
  2         1887  
6              
7             our $VERSION = "0.01";
8              
9             require XSLoader;
10             XSLoader::load('Linux::TempFile', $VERSION);
11              
12 2     2   14344 use Carp ();
  2         4  
  2         36  
13 2     2   10 use File::Spec;
  2         4  
  2         314  
14              
15             sub new {
16 1     1 1 11 my ($class, $dir) = @_;
17 1 50       127 $dir = File::Spec->tmpdir unless defined $dir;
18 1         112 my $fd = _open_tmpfile($dir);
19 0           my $self = $class->SUPER::new();
20 0           $self->fdopen($fd, '+>');
21             }
22              
23             sub link {
24 0     0 1   my ($self, $newpath) = @_;
25 0 0         Carp::croak("path required") unless length $newpath;
26 0           my $oldpath = '/proc/self/fd/' . fileno $self;
27 0           _linkat($oldpath => $newpath);
28             }
29              
30             1;
31             __END__