ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/fdate.c
(Generate patch)

Comparing ray/src/common/fdate.c (file contents):
Revision 2.4 by greg, Mon Oct 24 13:47:25 1994 UTC vs.
Revision 2.11 by greg, Fri Feb 10 18:29:46 2023 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1994 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
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  <sys/types.h>
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(fname)                            /* get file date */
23 < char  *fname;
22 > fdate(                          /* get file date */
23 >        const char  *fname
24 > )
25   {
26          struct stat  sbuf;
27  
28 <        if (stat(fname, &sbuf) == -1)
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(fname, ftim)                   /* set file date */
50 < char  *fname;
51 < long  ftim;
49 > setfdate(                       /* set file date */
50 >        const char  *fname,
51 >        long  ftim
52 > )
53   {
54 <        time_t  ftm[2];
54 >        struct utimbuf utb;
55  
56 <        ftm[0] = ftm[1] = ftim;
56 >        utb.actime = utb.modtime = ftim;
57  
58 <        return(utime(fname, ftm));
58 >        return(utime(fname, &utb));
59   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines