1 |
#ifndef lint |
2 |
static const char RCSid[] = "$Id: fdate.c,v 2.9 2016/03/06 01:13:17 schorsch Exp $"; |
3 |
#endif |
4 |
/* |
5 |
* Return file date (UNIX seconds as returned by time(2) call) |
6 |
* |
7 |
* External symbols declared in rtio.h |
8 |
*/ |
9 |
|
10 |
#include "copyright.h" |
11 |
|
12 |
#include "rtio.h" |
13 |
#include <sys/stat.h> |
14 |
#if defined(_WIN32) || defined(_WIN64) |
15 |
#include <sys/utime.h> |
16 |
#else |
17 |
#include <utime.h> |
18 |
#endif |
19 |
|
20 |
|
21 |
time_t |
22 |
fdate( /* get file date */ |
23 |
char *fname |
24 |
) |
25 |
{ |
26 |
struct stat sbuf; |
27 |
|
28 |
if (stat(fname, &sbuf) == -1) |
29 |
return(0); |
30 |
|
31 |
return(sbuf.st_mtime); |
32 |
} |
33 |
|
34 |
|
35 |
int |
36 |
setfdate( /* set file date */ |
37 |
char *fname, |
38 |
long ftim |
39 |
) |
40 |
{ |
41 |
struct utimbuf utb; |
42 |
|
43 |
utb.actime = utb.modtime = ftim; |
44 |
|
45 |
return(utime(fname, &utb)); |
46 |
} |