2015-10-25 09:12:53 +00:00
|
|
|
#pragma once
|
2021-04-12 06:34:26 +00:00
|
|
|
#include <stdint.h>
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2009-12-28 22:22:50 +00:00
|
|
|
class CFileBase
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
|
|
|
public:
|
2016-01-12 19:09:01 +00:00
|
|
|
enum OpenFlags
|
2015-11-06 11:37:21 +00:00
|
|
|
{
|
2021-04-14 05:34:15 +00:00
|
|
|
modeRead = 0x0000,
|
|
|
|
modeWrite = 0x0001,
|
|
|
|
modeReadWrite = 0x0002,
|
|
|
|
shareCompat = 0x0000,
|
|
|
|
shareExclusive = 0x0010,
|
|
|
|
shareDenyWrite = 0x0020,
|
|
|
|
shareDenyRead = 0x0030,
|
|
|
|
shareDenyNone = 0x0040,
|
|
|
|
modeNoInherit = 0x0080,
|
|
|
|
modeCreate = 0x1000,
|
|
|
|
modeNoTruncate = 0x2000,
|
2015-10-25 09:12:53 +00:00
|
|
|
};
|
|
|
|
|
2022-07-11 10:00:25 +00:00
|
|
|
enum SeekPosition
|
|
|
|
{
|
|
|
|
begin = 0x0,
|
|
|
|
current = 0x1,
|
|
|
|
end = 0x2
|
2021-04-14 05:34:15 +00:00
|
|
|
};
|
2015-10-25 09:12:53 +00:00
|
|
|
|
|
|
|
virtual bool Open(const char * lpszFileName, uint32_t nOpenFlags ) = 0;
|
|
|
|
|
|
|
|
virtual uint32_t GetPosition() const = 0;
|
2016-01-12 19:09:01 +00:00
|
|
|
virtual int32_t Seek(int32_t lOff, SeekPosition nFrom) = 0;
|
2015-10-25 09:12:53 +00:00
|
|
|
virtual bool SetLength(uint32_t dwNewLen) = 0;
|
|
|
|
virtual uint32_t GetLength() const = 0;
|
|
|
|
|
2015-11-11 06:47:22 +00:00
|
|
|
virtual uint32_t Read(void* lpBuf, uint32_t nCount) = 0;
|
|
|
|
virtual bool Write(const void* lpBuf, uint32_t nCount) = 0;
|
2015-10-25 09:12:53 +00:00
|
|
|
|
|
|
|
virtual bool Flush() = 0;
|
|
|
|
virtual bool Close() = 0;
|
|
|
|
virtual bool IsOpen() const = 0;
|
|
|
|
virtual bool SetEndOfFile() = 0;
|
2009-12-28 22:22:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class CFile : public CFileBase
|
|
|
|
{
|
|
|
|
public:
|
2015-10-25 09:12:53 +00:00
|
|
|
CFile();
|
|
|
|
CFile(void * hFile);
|
|
|
|
CFile(const char * lpszFileName, uint32_t nOpenFlags);
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2015-10-25 09:12:53 +00:00
|
|
|
virtual ~CFile();
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2015-10-25 09:12:53 +00:00
|
|
|
virtual bool Open(const char * lpszFileName, uint32_t nOpenFlags );
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2022-07-11 10:00:25 +00:00
|
|
|
uint32_t SeekToEnd ( void );
|
|
|
|
void SeekToBegin ( void );
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2015-10-25 09:12:53 +00:00
|
|
|
virtual uint32_t GetPosition() const;
|
2016-01-12 19:09:01 +00:00
|
|
|
virtual int32_t Seek(int32_t lOff, SeekPosition nFrom);
|
2015-10-25 09:12:53 +00:00
|
|
|
virtual bool SetLength(uint32_t dwNewLen);
|
|
|
|
virtual uint32_t GetLength() const;
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2015-11-11 06:47:22 +00:00
|
|
|
virtual uint32_t Read(void* lpBuf, uint32_t nCount);
|
|
|
|
virtual bool Write(const void* lpBuf, uint32_t nCount);
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2015-10-25 09:12:53 +00:00
|
|
|
virtual bool Flush();
|
|
|
|
virtual bool Close();
|
|
|
|
virtual bool IsOpen() const;
|
|
|
|
virtual bool SetEndOfFile();
|
2016-01-12 19:09:01 +00:00
|
|
|
|
|
|
|
private:
|
2021-04-13 00:07:11 +00:00
|
|
|
CFile(const CFile&);
|
|
|
|
CFile& operator=(const CFile&);
|
2022-07-11 10:00:25 +00:00
|
|
|
|
|
|
|
void * m_hFile;
|
|
|
|
bool m_bCloseOnDelete;
|
2008-09-18 03:15:49 +00:00
|
|
|
};
|