23 #ifndef BAGEL_BOFLIB_FILE_H 24 #define BAGEL_BOFLIB_FILE_H 26 #include "common/algorithm.h" 27 #include "common/memstream.h" 28 #include "common/stream.h" 29 #include "bagel/boflib/stdinc.h" 30 #include "bagel/boflib/object.h" 31 #include "bagel/boflib/error.h" 35 #define CBF_TEXT 0x00000001 36 #define CBF_BINARY 0x00000002 37 #define CBF_READONLY 0x00000004 38 #define CBF_OVERWRITE 0x00000008 39 #define CBF_SHARED 0x00000010 40 #define CBF_CREATE 0x00000020 41 #define CBF_SAVEFILE 0x100 43 #define CBF_DEFAULT (CBF_BINARY | CBF_READONLY) 45 #define CBOFFILE_TEXT CBF_TEXT 46 #define CBOFFILE_READONLY CBF_READONLY 47 #define CBOFFILE_OVERWRITE CBF_OVERWRITE 49 #define CBOFFILE_DEFAULT CBF_DEFAULT 57 bool eos()
const override {
58 return _owner->
pos() >= _owner->
size();
60 uint32
read(
void *dataPtr, uint32 dataSize)
override {
61 int bytesToCopy = MIN<int>(dataSize, _owner->
size() - _owner->
pos());
62 const byte *src = _owner->getData() + _owner->
pos();
64 seek(bytesToCopy, SEEK_CUR);
87 int64
pos()
const override {
90 bool seek(int64 offset,
int whence = SEEK_SET)
override {
93 int64
size()
const override {
100 char _szFileName[MAX_FNAME];
102 uint32 _lFlags = CBF_DEFAULT;
115 CBofFile(
const char *pszFileName, uint32 lFlags = CBF_DEFAULT);
127 ErrorCode open(
const char *pszFileName, uint32 lFlags = CBF_DEFAULT);
134 ErrorCode create(
const char *pszFileName, uint32 lFlags = CBF_DEFAULT | CBF_CREATE);
139 virtual ErrorCode close();
147 virtual ErrorCode
read(
void *pDestBuf, int32 lBytes);
155 virtual ErrorCode write(
const void *pSrcBuf, int32 lBytes);
167 return (setPosition(lPos));
175 return (setPosition(0));
182 ErrorCode seekToEnd();
188 ErrorCode setPosition(uint32 lPos);
193 uint32 getPosition();
uint32 read(void *dataPtr, uint32 dataSize) override
Definition: file.h:60
int64 size() const override
Definition: file.h:93
virtual bool seek(int64 offset, int whence=SEEK_SET)=0
int64 size() const override
Definition: memstream.h:250
int64 pos() const override
Definition: memstream.h:249
Definition: memstream.h:194
Out copy(In first, In last, Out dst)
Definition: algorithm.h:52
bool seek(int64 offs, int whence=SEEK_SET) override
Definition: memstream.h:254
int64 pos() const override
Definition: file.h:87
bool eos() const override
Definition: file.h:57
ErrorCode seekToBeginning()
Definition: file.h:174
bool seek(int64 offset, int whence=SEEK_SET) override
Definition: file.h:90
virtual uint32 write(const void *dataPtr, uint32 dataSize)=0
ErrorCode seek(uint32 lPos)
Definition: file.h:166