home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / comms / comprgs / osrc_149.lzh / stat.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-12-20  |  1019 b   |  49 lines

  1. #include "stat.h"
  2. #include "dos.h"
  3. #include "time.h"
  4.  
  5. #include    <exec/types.h>
  6. #include    <exec/memory.h>
  7. #include    <libraries/dos.h>
  8.  
  9. #include    <proto/exec.h>
  10. #include    <proto/dos.h>
  11.  
  12. int stat(char *name,struct stat *status)
  13. {
  14.     BPTR    lock;
  15.     struct FileInfoBlock *fib;
  16.     unsigned long t;
  17.     struct tm *time;
  18.     int retval = -1;
  19.  
  20.     fib = AllocMem(sizeof(struct FileInfoBlock), MEMF_PUBLIC);
  21.     if (fib) {
  22.         if(lock=Lock(name,ACCESS_READ)) {
  23.             if(Examine(lock,fib)) {
  24.                 status->st_size=fib->fib_Size;
  25.  
  26.                 t=(365*8+2)*24*3600;
  27.                 t+=fib->fib_Date.ds_Days*24*3600;
  28.                 t+=fib->fib_Date.ds_Minute*3600;
  29.                 t+=fib->fib_Date.ds_Tick/50;
  30.  
  31.                 time=localtime(&t);
  32.  
  33.                 status->st_atime=time->tm_mday;
  34.                 status->st_atime+=time->tm_mon*256l;
  35.                 status->st_atime+=time->tm_year*16384l;
  36.  
  37.                 retval = 0;
  38.             }
  39.             UnLock(lock);
  40.         }
  41.         FreeMem(fib, sizeof(struct FileInfoBlock));
  42.     }
  43.  
  44.     return retval;
  45. }
  46.  
  47. /*-------------------------------------------------------------------------*/
  48. /* ID: 1.1@958  Last Changed: 16 Oct 1989 08:27:50 by max */
  49.