home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OS9000 / APPS / rcs.lzh / rcs1 / utime.c < prev    next >
C/C++ Source or Header  |  1996-04-20  |  717b  |  41 lines

  1. #include    <modes.h>
  2. #ifdef _OS9000
  3. #include    <rbf.h>
  4. #define        fildes    fd_stats
  5. #else
  6. #include    <direct.h>
  7. #endif
  8. #include    "utime.h"
  9.  
  10. int utime( pathname, timep)
  11. char    *pathname;
  12. struct    utimbuf *timep;
  13. {
  14.     int         path,rc;
  15.     struct  fildes dp;
  16.     struct    tm    *tp;
  17.  
  18.     if( ( path = open( pathname, S_IREAD|S_IWRITE) ) < 0 ) return(-1);
  19.  
  20.     if( _gs_gfd( path, &dp , sizeof(dp) ) < 0 ) 
  21.     {
  22.         close(path);
  23.         return(-1);
  24.     }
  25.  
  26. #ifdef _OS9000
  27.     dp.fd_utime = *(time_t *)timep;
  28. #else
  29.     tp = localtime((time_t *)timep);
  30.     dp.fd_date[0] = tp->tm_year;
  31.     dp.fd_date[1] = tp->tm_mon+1;
  32.     dp.fd_date[2] = tp->tm_mday;
  33.     dp.fd_date[3] = tp->tm_hour;
  34.     dp.fd_date[4] = tp->tm_min;
  35. #endif
  36.     rc = _ss_pfd(path, &dp ,  sizeof(dp));
  37.     close(path);
  38.     return(rc);
  39. }
  40.  
  41.