utime2.xs

filter: Statementstmt 100% 12 / 12 Branchbran 83.3% 5 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 94.4% 17 / 18 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
↑ Summary blib/lib/utime2.pm »
1 #include "EXTERN.h"
2 #include "perl.h"
3 #include "XSUB.h"
4  
5 #include "ppport.h"
6  
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <sys/types.h>
10 #include <sys/stat.h>
11 #include <unistd.h>
12 #include <sys/time.h>
13 #include <utime.h>
14 #include <fcntl.h>
15  
16 4 struct timespec d2t (double d)
17 {
18 struct timespec ts;
19 4 ts.tv_sec = d;
20 4 ts.tv_nsec = 1000000000 * (d - (unsigned long long)d);
21 4 return ts;
22 }
23  
24 MODULE = utime2 PACKAGE = utime2
25  
26 int
27 utime2 (atime, mtime, path)
28 double atime
29 double mtime
30 const char * path
31 INIT:
32 struct timespec ts[2];
33 int fd;
34 int rc;
35 CODE:
36 2 ts[0] = d2t (atime);
37 2 ts[1] = d2t (mtime);
38  
39 2 rc = 0;
40  
41 2 ▶ if ((fd = open (path, O_RDONLY)) >= 0)
Branch: 1 branch
BranchTrueFalseTotal
if ((fd = open (path, O_RDONLY)) >= 0) 1 1 2
42 {
43 1 ▶ if (futimens (fd, ts) == 0)
Branch: 1 branch
BranchTrueFalseTotal
if (futimens (fd, ts) == 0) 1 0 1
44 1 rc = 1;
45 1 close (fd);
46 }
47
48 2 ▶ RETVAL = rc;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = rc; 1 1 2
49  
50 OUTPUT:
51 RETVAL
52  
53  
54  
↑ Summary blib/lib/utime2.pm »