ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/fdate.c
Revision: 2.11
Committed: Fri Feb 10 18:29:46 2023 UTC (14 months, 2 weeks ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad5R4, HEAD
Changes since 2.10: +18 -5 lines
Log Message:
feat: Added fddate() call to get modification time from open file

File Contents

# Content
1 #ifndef lint
2 static const char RCSid[] = "$Id: fdate.c,v 2.10 2019/02/27 21:30:01 greg 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 const char *fname
24 )
25 {
26 struct stat sbuf;
27
28 if (stat(fname, &sbuf) < 0)
29 return(0);
30
31 return(sbuf.st_mtime);
32 }
33
34
35 time_t
36 fddate( /* get file descriptor date */
37 int fd
38 )
39 {
40 struct stat sbuf;
41
42 if (fstat(fd, &sbuf) < 0)
43 return(0);
44
45 return(sbuf.st_mtime);
46 }
47
48 int
49 setfdate( /* set file date */
50 const char *fname,
51 long ftim
52 )
53 {
54 struct utimbuf utb;
55
56 utb.actime = utb.modtime = ftim;
57
58 return(utime(fname, &utb));
59 }