#ifndef __RECFILE_HPP #define __RECFILE_HPP class File; typedef unsigned long RecordID; struct RecordFile_FileHeader; struct RecordFile_ClusterBitmap; class RecordFile { public: RecordFile(); virtual ~RecordFile(); int open(File *fp); int create(File *fp, unsigned long customSize, unsigned long recordSize); int createtrunc(File *fp, unsigned long customSize, unsigned long recordSize); unsigned long getRecordSize() const; //custom header i/o unsigned long getCustomHeaderSize() const; int readCustomHeader(void *buf) const; int writeCustomHeader(const void *buf); //record i/o RecordID addRecord(const void *buf, RecordID around=0); int getRecord(RecordID rid, void *buf) const; int updateRecord(RecordID rid, const void *buf); RecordID removeRecord(RecordID rid); RecordID firstRecord(); RecordID nextRecord(RecordID rid); private: RecordID findNextUsedRecord(RecordID rid); void rid2cnorno(RecordID rid, unsigned long &cno, unsigned long &rno); void cnorno2rid(unsigned long cno, unsigned long rno, RecordID& rid); File *file; unsigned long recordSize; unsigned long firstClusterOffset; unsigned long clusterBytes; typedef RecordFile_FileHeader FileHeader; typedef RecordFile_ClusterBitmap ClusterBitmap; static int validateHeader(const FileHeader &h); int readHeader(FileHeader &h) const; int writeHeader(const FileHeader &h); int validateRecordID(RecordID rid) const; RecordID findFreeRecord(RecordID around); int readClusterBitmap(unsigned long cno, ClusterBitmap& cluster); int writeClusterBitmap(unsigned long cno, const ClusterBitmap& cluster); int createNewCluster(); void markRecord(RecordID rid, int bit); }; #endif