home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / BTMTSRC3.ZIP / FILETIME.C < prev    next >
Text File  |  1990-02-09  |  3KB  |  92 lines

  1. /*--------------------------------------------------------------------------*/
  2. /* Include files                                                            */
  3. /*--------------------------------------------------------------------------*/
  4.  
  5. #ifndef OS_2
  6. #error    This Module only for OS/2
  7. #endif
  8. #include    <ctype.h>
  9. #include    <errno.h>
  10. #include    <stdio.h>
  11.  
  12. #include    <stdlib.h>
  13. #include    <fcntl.h>
  14. #include    <sys\types.h>
  15. #include    <sys\stat.h>
  16. #include    <io.h>
  17.  
  18. #define     INCL_DOSFILEMGR
  19. #include    <os2.h>
  20.  
  21. #include    <string.h>
  22. #include    <dos.h>
  23. #include    <time.h>
  24.  
  25. /*--------------------------------------------------------------------------*/
  26. /* Static function declarations                                             */
  27. /*--------------------------------------------------------------------------*/
  28.  
  29. /*    ... NONE ...  */
  30.  
  31. /*--------------------------------------------------------------------------*/
  32. /* Static variable definitions                                                */
  33. /*--------------------------------------------------------------------------*/
  34.  
  35. struct FileTimeBuf {
  36.         unsigned c_date;           /* date of file creation */
  37.         unsigned c_time;           /* time of file creation */
  38.         unsigned a_date;           /* date of last access */
  39.         unsigned a_time;           /* time of last access */
  40.         unsigned w_date;               /* date of last write */
  41.         unsigned w_time;               /* time of last write */
  42.         } ;
  43.  
  44. static struct FileTimeBuf TimeBuf;
  45.  
  46. /*--------------------------------------------------------------------------*/
  47. /* External variable declarations                                            */
  48. /*--------------------------------------------------------------------------*/
  49.  
  50. /*    ... NONE ...  */
  51.  
  52. /*--------------------------------------------------------------------------*/
  53. /* Locally defined globals                                                    */
  54. /*--------------------------------------------------------------------------*/
  55.  
  56. /*    ... NONE ...  */
  57.  
  58. /*--------------------------------------------------------------------------*/
  59. /* Local constants                                                            */
  60. /*--------------------------------------------------------------------------*/
  61.  
  62. /*    ... NONE ...  */
  63.  
  64. /****************************************************************************/
  65.  
  66. /*--------------------------------------------------------------------------*/
  67. /* set_fileinfo                                      FOR PORTABILITY        */
  68. /*--------------------------------------------------------------------------*/
  69.  
  70.  
  71. void set_fileinfo(int fh, unsigned date, unsigned time)
  72. {
  73.  
  74.     if ((time/2048) < (unsigned)(timezone/3600L)) {
  75.        TimeBuf.a_date = TimeBuf.w_date = TimeBuf.c_date = date-1;
  76.        TimeBuf.c_time = time+((unsigned)(86400-((unsigned)(timezone/3600L)*2048)));
  77.        TimeBuf.a_time = TimeBuf.w_time = TimeBuf.c_time;
  78.     } else {
  79.        TimeBuf.a_date = TimeBuf.w_date = TimeBuf.c_date = date;
  80.        TimeBuf.c_time = time-((unsigned)(timezone/3600L)*2048);
  81.        TimeBuf.a_time = TimeBuf.w_time = TimeBuf.c_time;
  82.     }
  83.     (void) DosSetFileInfo((HFILE) fh,
  84.        (USHORT) 1,
  85.        (PBYTE) &TimeBuf,
  86.        (USHORT) 12);
  87. }
  88.  
  89. /*--------------------------------------------------------------------------*/
  90. /*                                  END OF FILE                                */
  91. /*--------------------------------------------------------------------------*/
  92.