home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 9 / FreshFishVol9-CD2.bin / bbs / gnu / libnix-0.8-src.lha / libnix-0.8 / sources / nix / extra / __stat.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-12  |  1.2 KB  |  34 lines

  1. #include <sys/types.h>
  2. #include <sys/stat.h>
  3. #include <dos/dosextens.h>
  4.  
  5. int __stat(struct stat *buf,struct FileInfoBlock *fib)
  6. {
  7.    buf->st_dev=0;
  8.    buf->st_ino=fib->fib_DiskKey;
  9.    buf->st_mode=
  10.      (fib->fib_DirEntryType<0?S_IFREG:
  11.         (fib->fib_DirEntryType!=ST_SOFTLINK?S_IFDIR:S_IFLNK))|
  12.      (fib->fib_Protection&FIBF_READ?0:S_IRUSR)|
  13.      (fib->fib_Protection&FIBF_WRITE?0:S_IWUSR)|
  14.      (fib->fib_Protection&FIBF_EXECUTE?0:S_IXUSR)|
  15.      (fib->fib_Protection&FIBF_GRP_READ?S_IRGRP:0)|
  16.      (fib->fib_Protection&FIBF_GRP_WRITE?S_IWGRP:0)|
  17.      (fib->fib_Protection&FIBF_GRP_EXECUTE?S_IXGRP:0)|
  18.      (fib->fib_Protection&FIBF_OTR_READ?S_IROTH:0)|
  19.      (fib->fib_Protection&FIBF_OTR_WRITE?S_IWOTH:0)|
  20.      (fib->fib_Protection&FIBF_OTR_EXECUTE?S_IXOTH:0);
  21.    buf->st_nlink=0;
  22.    buf->st_uid=fib->fib_OwnerUID;
  23.    buf->st_gid=fib->fib_OwnerGID;
  24.    buf->st_rdev=0;
  25.    buf->st_size=fib->fib_Size;
  26.    buf->st_atime=buf->st_mtime=buf->st_ctime=
  27.      ((fib->fib_Date.ds_Days+2922)*1440+fib->fib_Date.ds_Minute)*60+
  28.      fib->fib_Date.ds_Tick/TICKS_PER_SECOND;
  29.    buf->st_spare1=buf->st_spare2=buf->st_spare3=0;
  30.    buf->st_blksize=512;
  31.    buf->st_blocks=fib->fib_NumBlocks;
  32.    return 0;
  33. }
  34.