23 #ifndef BAGEL_BOFLIB_DAT_FILE_H 24 #define BAGEL_BOFLIB_DAT_FILE_H 26 #include "common/serializer.h" 27 #include "bagel/boflib/file.h" 31 #define CDF_NOFLAGS 0x00000000 32 #define CDF_READONLY CBF_READONLY // Open for Read-only access 33 #define CDF_OVERWRITE CBF_OVERWRITE // *Overwrite any existing data-file 34 #define CDF_SHARED CBF_SHARED // *Open for Shared access 35 #define CDF_CREATE CBF_CREATE // *Create new file if not exist 36 #define CDF_SAVEFILE CBF_SAVEFILE 38 #define CDF_MEMORY 0x00010000 // *header/footer should stay in memory 39 #define CDF_ENCRYPT 0x00020000 // Specifies if data should use encryption 40 #define CDF_KEEPOPEN 0x00040000 // File should be kept open after construction 41 #define CDF_COMPRESSED 0x00080000 // *Specifies if data should be compressed 44 #define CDF_DEFAULT (CDF_MEMORY | CDF_ENCRYPT | CDF_SHARED | CDF_KEEPOPEN | CDF_READONLY) 46 #define MAX_PW_LEN 32 // Max Password length 56 static int size() {
return 16; }
66 static int size() {
return 16; }
71 char _szPassWord[MAX_PW_LEN];
72 int32 _lHeaderLength = 0;
73 int32 _lHeaderStart = 0;
84 ErrorCode readHeader();
90 ErrorCode writeHeader();
109 ErrorCode setFile(
const char *pszFileName, uint32 lFlags);
115 ErrorCode releaseFile();
122 int32 getRecSize(int32 lRecNum);
123 int32 getNumberOfRecs()
const {
131 int32 getMaxRecSize()
const;
143 ErrorCode close()
override;
157 ErrorCode readRecord(int32 lRecNum,
void *pBuf);
164 ErrorCode readFromFile(int32 lRecNum,
void *pBuf, int32 lBytes);
175 ErrorCode writeRecord(int32 lRecNum,
void *pBuf, int32 lSize = -1,
bool bUpdateHeader =
false, uint32 lKey = 0xFFFFFFFF);
182 ErrorCode verifyRecord(int32 lRecNum);
188 ErrorCode verifyAllRecords();
198 ErrorCode addRecord(
void *pBuf, int32 lLength,
bool bUpdateHeader =
false, uint32 lKey = 0xFFFFFFFF);
205 int32 findRecord(uint32 lKey);
211 void setPassword(
const char *pszPassword);
212 const char *getPassword()
const {
222 ErrorCode read(
void *pDestBuf, int32 lBytes)
override;
232 ErrorCode write(
const void *pSrcBuf, int32 lBytes)
override;
Definition: dat_file.h:69
Definition: serializer.h:79
Definition: dat_file.h:59