home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_09_12 / 9n12103a < prev    next >
Text File  |  1991-10-30  |  2KB  |  36 lines

  1. //  Listing 2 - Header file for binaryfile class 
  2. //  This contains the class's elements and in-line functions
  3. //
  4.  
  5. enum FILEMODE  {Readonly, Update, AnyWrite, Append, Recreate};
  6. enum READMODE  {FirstRecord, NextRecord, PreviousRecord, LastRecord};
  7. enum SHAREMODE {NoneShared, ReadShared, WriteShared};
  8.  
  9. class binaryfile {
  10. private:
  11.     char name[81];      // name of file  (size is DOS specific)
  12.     enum FILEMODE mode;   // access mode of the file
  13.     enum SHAREMODE share; // whether shared access is allowed
  14.     unsigned length;      // record length
  15.     int      handle;      // file handle  (-1 if not open)
  16.     long     header;      // size of header at start of file
  17.     long     count;       // number of records in the file
  18.     long     recnbr;      // current record number (starting at 1)
  19.     long     locked;      // if >0, currently locked record
  20.     long     countrecords();  // prototype of private function
  21. public:
  22.     char     *record;     // pointer to record area
  23.     // inline functions to read private elements
  24.     long     getcount  ()      {
  25.         return (share == WriteShared ? countrecords() : count);
  26.     };
  27.     long     getheader ()      {return header;};
  28.     unsigned getlength ()      {return length;};
  29.     long     getlocked ()      {return locked;};
  30.     enum FILEMODE getmode ()   {return mode;};
  31.     char*    getname (char *n) {return (strcpy (n, name));};
  32.     long     getrecnbr ()      {return recnbr;};
  33.     enum SHAREMODE getshare()  {return share;};
  34.     int      isopen ()         {return (handle >= 0);};
  35. };
  36.