home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_11_07 / unixfile.c < prev    next >
Text File  |  1993-01-07  |  871b  |  33 lines

  1. /*** UnixFile Class Implementation: unixfile.c ***/
  2.  
  3. #include "file.h"
  4. #include "unixfile.h"
  5.  
  6. CONSTRUCTOR(UnixFile,(const char *name,int flags,int mode))
  7. CONSTRUCT(File,())
  8.     this->descriptor = open(name,flags,mode);
  9.     assert(this->descriptor >= 0);
  10. END_CONSTRUCTOR
  11.  
  12. DESTRUCTOR(UnixFile)
  13.     close(this->descriptor);
  14. END_DESTRUCTOR
  15.  
  16. METHOD(UnixFile, Seek, (long offset, int whence), long)
  17.    return lseek(this->descriptor,offset,whence);
  18. END_METHOD
  19.  
  20. METHOD(UnixFile, Read, (void *buffer, int nbytes), int)
  21.    return read(this->descriptor,buffer,nbytes);
  22. END_METHOD
  23.  
  24. METHOD(UnixFile, Write, (void *buffer, int nbytes), int)
  25.    return write(this->descriptor,buffer,nbytes);
  26. END_METHOD
  27.  
  28. DEF_CLASS(UnixFile,File)
  29.     REDEF_METHOD(UnixFile,File,Seek);
  30.     REDEF_METHOD(UnixFile,File,Read);
  31.     REDEF_METHOD(UnixFile,File,Write);
  32. END_CLASS
  33.