[Project64] get CFile class to use standard types
This commit is contained in:
parent
5012979377
commit
a2a8eccbca
|
@ -1,90 +1,86 @@
|
||||||
#ifndef __FILE_CLASS__H__
|
#pragma once
|
||||||
#define __FILE_CLASS__H__
|
|
||||||
|
#include "stdtypes.h"
|
||||||
|
|
||||||
class CFileBase
|
class CFileBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum OpenFlags {
|
enum OpenFlags {
|
||||||
modeRead = 0x0000,
|
modeRead = 0x0000,
|
||||||
modeWrite = 0x0001,
|
modeWrite = 0x0001,
|
||||||
modeReadWrite = 0x0002,
|
modeReadWrite = 0x0002,
|
||||||
shareCompat = 0x0000,
|
shareCompat = 0x0000,
|
||||||
shareExclusive = 0x0010,
|
shareExclusive = 0x0010,
|
||||||
shareDenyWrite = 0x0020,
|
shareDenyWrite = 0x0020,
|
||||||
shareDenyRead = 0x0030,
|
shareDenyRead = 0x0030,
|
||||||
shareDenyNone = 0x0040,
|
shareDenyNone = 0x0040,
|
||||||
modeNoInherit = 0x0080,
|
modeNoInherit = 0x0080,
|
||||||
modeCreate = 0x1000,
|
modeCreate = 0x1000,
|
||||||
modeNoTruncate = 0x2000,
|
modeNoTruncate = 0x2000,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Attribute {
|
enum Attribute {
|
||||||
normal = 0x00,
|
normal = 0x00,
|
||||||
readOnly = 0x01,
|
readOnly = 0x01,
|
||||||
hidden = 0x02,
|
hidden = 0x02,
|
||||||
system = 0x04,
|
system = 0x04,
|
||||||
volume = 0x08,
|
volume = 0x08,
|
||||||
directory = 0x10,
|
directory = 0x10,
|
||||||
archive = 0x20
|
archive = 0x20
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SeekPosition { begin = 0x0, current = 0x1, end = 0x2 };
|
enum SeekPosition { begin = 0x0, current = 0x1, end = 0x2 };
|
||||||
|
|
||||||
virtual bool Open(LPCTSTR lpszFileName, ULONG nOpenFlags ) = 0;
|
virtual bool Open(const char * lpszFileName, uint32_t nOpenFlags ) = 0;
|
||||||
|
|
||||||
virtual ULONG GetPosition() const = 0;
|
virtual uint32_t GetPosition() const = 0;
|
||||||
virtual long Seek(long lOff, SeekPosition nFrom) = 0;
|
virtual long Seek(long lOff, SeekPosition nFrom) = 0;
|
||||||
virtual bool SetLength(ULONG dwNewLen) = 0;
|
virtual bool SetLength(uint32_t dwNewLen) = 0;
|
||||||
virtual ULONG GetLength() const = 0;
|
virtual uint32_t GetLength() const = 0;
|
||||||
|
|
||||||
virtual ULONG Read(void* lpBuf, ULONG nCount) = 0;
|
virtual uint32_t Read(void* lpBuf, uint32_t nCount) = 0;
|
||||||
virtual bool Write(const void* lpBuf, ULONG nCount) = 0;
|
virtual bool Write(const void* lpBuf, uint32_t nCount) = 0;
|
||||||
|
|
||||||
virtual bool Flush() = 0;
|
virtual bool Flush() = 0;
|
||||||
virtual bool Close() = 0;
|
virtual bool Close() = 0;
|
||||||
virtual bool IsOpen() const = 0;
|
virtual bool IsOpen() const = 0;
|
||||||
virtual bool SetEndOfFile() = 0;
|
virtual bool SetEndOfFile() = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class CFile : public CFileBase
|
class CFile : public CFileBase
|
||||||
{
|
{
|
||||||
|
// Attributes
|
||||||
|
void * m_hFile;
|
||||||
|
bool m_bCloseOnDelete;
|
||||||
|
|
||||||
// Attributes
|
|
||||||
HANDLE m_hFile;
|
|
||||||
bool m_bCloseOnDelete;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Flag values
|
// Flag values
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
CFile();
|
CFile();
|
||||||
CFile(HANDLE hFile);
|
CFile(void * hFile);
|
||||||
CFile(LPCTSTR lpszFileName, ULONG nOpenFlags);
|
CFile(const char * lpszFileName, uint32_t nOpenFlags);
|
||||||
|
|
||||||
// Deconstructors
|
// Deconstructors
|
||||||
virtual ~CFile();
|
virtual ~CFile();
|
||||||
|
|
||||||
|
// Operations
|
||||||
|
virtual bool Open(const char * lpszFileName, uint32_t nOpenFlags );
|
||||||
|
|
||||||
// Operations
|
uint32_t SeekToEnd ( void );
|
||||||
virtual bool Open(LPCTSTR lpszFileName, ULONG nOpenFlags );
|
void SeekToBegin ( void );
|
||||||
|
|
||||||
ULONG SeekToEnd ( void );
|
// Overridables
|
||||||
void SeekToBegin ( void );
|
virtual uint32_t GetPosition() const;
|
||||||
|
virtual long Seek(long lOff, SeekPosition nFrom);
|
||||||
|
virtual bool SetLength(uint32_t dwNewLen);
|
||||||
|
virtual uint32_t GetLength() const;
|
||||||
|
|
||||||
// Overridables
|
virtual uint32_t Read(void* lpBuf, uint32_t nCount);
|
||||||
virtual ULONG GetPosition() const;
|
virtual bool Write(const void* lpBuf, uint32_t nCount);
|
||||||
virtual long Seek(long lOff, SeekPosition nFrom);
|
|
||||||
virtual bool SetLength(ULONG dwNewLen);
|
|
||||||
virtual ULONG GetLength() const;
|
|
||||||
|
|
||||||
virtual ULONG Read(void* lpBuf, ULONG nCount);
|
virtual bool Flush();
|
||||||
virtual bool Write(const void* lpBuf, ULONG nCount);
|
virtual bool Close();
|
||||||
|
virtual bool IsOpen() const;
|
||||||
virtual bool Flush();
|
virtual bool SetEndOfFile();
|
||||||
virtual bool Close();
|
|
||||||
virtual bool IsOpen() const;
|
|
||||||
virtual bool SetEndOfFile();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
Loading…
Reference in New Issue