#ifndef __bufio_h #define __bufio_h #pragma interface class bufio { long bufpos; // file position of buffer long tmpsize; // bytes saved in backing store char *buf; // buffer int fd; // os file descriptor int tfd; // temporary file for backing pipe input int bufsize; // size of buffer int bufcnt; // bytes currently in buffer int sectsize; // file position alignment required int curpos; // buffer position of current object int cursize; // size of current object bufio(const bufio &); bufio&operator=(const bufio &); public: long seek(long pos); bufio(int f,int bufsize = 8192,int sect = 512); void *read(long pos,int size); // read random object void *read(int size); // read next object long getpos() const { return bufpos + curpos + cursize; } int getcnt() const { return bufcnt - curpos - cursize; } int getfd() const { return fd; } int canSeek() const { return tfd == fd; } void setSequential(); // do not try to seek void update(); // mark current object updated ~bufio(); }; #endif