Back to index

radiance  4R0+20100331
fdate.c
Go to the documentation of this file.
00001 #ifndef lint
00002 static const char    RCSid[] = "$Id: fdate.c,v 2.8 2003/06/27 06:53:21 greg Exp $";
00003 #endif
00004 /*
00005  * Return file date (UNIX seconds as returned by time(2) call)
00006  *
00007  *  External symbols declared in rtio.h
00008  */
00009 
00010 #include "copyright.h"
00011 
00012 #include  "rtio.h"
00013 #include  <sys/stat.h>
00014 #ifdef _WIN32
00015   #include  <sys/utime.h>
00016 #else
00017   #include  <utime.h>
00018 #endif
00019 
00020 
00021 time_t
00022 fdate(fname)                       /* get file date */
00023 char  *fname;
00024 {
00025        struct stat  sbuf;
00026 
00027        if (stat(fname, &sbuf) == -1)
00028               return(0);
00029 
00030        return(sbuf.st_mtime);
00031 }
00032 
00033 
00034 int
00035 setfdate(fname, ftim)                     /* set file date */
00036 char  *fname;
00037 long  ftim;
00038 {
00039        struct utimbuf utb;
00040 
00041        utb.actime = utb.modtime = ftim;
00042        return(utime(fname, &utb));
00043 
00044 #ifdef NOTHING /* XXX does this work anywhere? */
00045        time_t  ftm[2];
00046 
00047        ftm[0] = ftm[1] = ftim;
00048        return(utime(fname, ftm));
00049 #endif
00050 }