OpenBarnyard
 
Loading...
Searching...
No Matches
TNativeFile_Win.h
Go to the documentation of this file.
1#pragma once
2#include "File/TFile.h"
3
5
7{
8public:
9 TNativeFileSystem( const TCHAR* name );
10 virtual ~TNativeFileSystem();
11
12 virtual TFile* CreateFile( const TString8& a_rcFileName, TFILEMODE a_eFileMode ) OVERRIDE;
13 virtual void DestroyFile( TFile* a_pFile ) OVERRIDE;
14 virtual TBOOL RemoveFile( const TString8& a_rcFileName ) OVERRIDE;
15 virtual TString8 MakeInternalPath( const TString8& a_rcPath ) OVERRIDE;
16 virtual TBOOL GetFirstFile( const TString8& a_rcPath, TString8& a_rOutFileName, TFINDFILE a_ui8Flags ) OVERRIDE;
17 virtual TBOOL GetNextFile( TString8& a_rOutFileName, TFINDFILE a_ui8Flags ) OVERRIDE;
18
19 virtual TBOOL MakeDirectory( const TString8& a_rcDirectory );
20};
21
22class TNativeFile : public TFile
23{
24public:
25 static constexpr TUINT32 BUFFER_SIZE = 0x800;
26
27public:
28 TNativeFile( TNativeFileSystem* a_pFileSystem );
29 TNativeFile( const TNativeFile& other );
31
32 //-----------------------------------------------------------------------------
33 // TFile
34 //-----------------------------------------------------------------------------
35 virtual TSIZE Read( void* a_pDst, TSIZE a_uiSize ) OVERRIDE;
36 virtual TSIZE Write( const void* a_pSrc, TSIZE a_uiSize ) OVERRIDE;
37 virtual TBOOL Seek( TINT a_iOffset, TSEEK a_eOrigin = TSEEK_CUR ) OVERRIDE;
38 virtual TSIZE Tell() OVERRIDE;
39 virtual void FlushBuffers() OVERRIDE;
40 virtual TSIZE GetSize() OVERRIDE;
41 virtual TUINT64 GetDate() OVERRIDE;
42 virtual TCHAR GetCChar() OVERRIDE;
43 virtual TWCHAR GetWChar() OVERRIDE;
44 virtual TINT PutCChar( TCHAR a_cCharacter ) OVERRIDE;
45 virtual TINT PutWChar( TWCHAR a_wcCharacter ) OVERRIDE;
46 virtual TINT CPrintf( const TCHAR* a_szFormat, ... ) OVERRIDE;
47 virtual TINT WPrintf( const TWCHAR* a_wszFormat, ... ) OVERRIDE;
48
49 TBOOL Open( const TString8& a_FileName, TFILEMODE a_Mode );
50
51 void Close();
52
53private:
54 TBOOL LoadBuffer( TUINT32 bufferPos );
55 TINT FlushWriteBuffer();
56 TINT ReadUnbuffered( void* dst, TUINT size );
57
58protected:
59 void* m_Handle; // 0x8
64 TCHAR* m_RBuffer; // 0x1C (read buffer)
65 TCHAR* m_WBuffer; // 0x20 (write buffer)
68};
69
Core file system interface for the Toshi engine.
TUINT8 TFINDFILE
Definition TFile.h:45
TUINT16 TFILEMODE
Definition TFile.h:35
TSEEK
Definition TFile.h:29
@ TSEEK_CUR
Definition TFile.h:31
#define OVERRIDE
Definition Defines.h:12
#define TOSHI_NAMESPACE_START
Definition Defines.h:47
#define TOSHI_NAMESPACE_END
Definition Defines.h:50
wchar_t TWCHAR
Definition Typedefs.h:21
unsigned int TUINT
Definition Typedefs.h:8
uint64_t TUINT64
Definition Typedefs.h:11
size_t TSIZE
Definition Typedefs.h:9
char TCHAR
Definition Typedefs.h:20
uint32_t TUINT32
Definition Typedefs.h:13
int TINT
Definition Typedefs.h:7
bool TBOOL
Definition Typedefs.h:6
TFileSystem(const TCHAR *a_szName)
Definition TFile.h:128
TFile(TFileSystem *a_pFS)
Definition TFile.cpp:13
TNativeFileSystem(const TCHAR *name)
virtual TBOOL GetFirstFile(const TString8 &a_rcPath, TString8 &a_rOutFileName, TFINDFILE a_ui8Flags) OVERRIDE
Finds out what's the first file at the specified path.
virtual TString8 MakeInternalPath(const TString8 &a_rcPath) OVERRIDE
Not documented.
virtual TBOOL MakeDirectory(const TString8 &a_rcDirectory)
virtual TBOOL GetNextFile(TString8 &a_rOutFileName, TFINDFILE a_ui8Flags) OVERRIDE
Not documented.
virtual TBOOL RemoveFile(const TString8 &a_rcFileName) OVERRIDE
Removes specified file.
virtual void DestroyFile(TFile *a_pFile) OVERRIDE
Destroys specified file.
virtual TFile * CreateFile(const TString8 &a_rcFileName, TFILEMODE a_eFileMode) OVERRIDE
Creates file.
TUINT32 m_WriteBufferUsed
TCHAR * m_RBuffer
TNativeFile(TNativeFileSystem *a_pFileSystem)
virtual TSIZE Write(const void *a_pSrc, TSIZE a_uiSize) OVERRIDE
Writes specified number of bytes to the file from the buffer.
TBOOL Open(const TString8 &a_FileName, TFILEMODE a_Mode)
TCHAR * m_WBuffer
virtual TINT PutWChar(TWCHAR a_wcCharacter) OVERRIDE
Writes one character of type wchar to the file.
virtual TINT PutCChar(TCHAR a_cCharacter) OVERRIDE
Writes one character of type TCHAR to the file.
static constexpr TUINT32 BUFFER_SIZE
virtual TSIZE Read(void *a_pDst, TSIZE a_uiSize) OVERRIDE
Reads specified number of bytes from the file into the buffer.
virtual TBOOL Seek(TINT a_iOffset, TSEEK a_eOrigin=TSEEK_CUR) OVERRIDE
Shifts current file cursor based on the specified offset and origin.
TBOOL m_WriteBuffered
virtual TSIZE GetSize() OVERRIDE
virtual void FlushBuffers() OVERRIDE
Flushes write buffers.
virtual TINT WPrintf(const TWCHAR *a_wszFormat,...) OVERRIDE
Analogue of wprintf but writes result to the file.
virtual TWCHAR GetWChar() OVERRIDE
Reads one character of type wchar from the file.
virtual TCHAR GetCChar() OVERRIDE
Reads one character of type TCHAR from the file.
virtual TUINT64 GetDate() OVERRIDE
virtual TINT CPrintf(const TCHAR *a_szFormat,...) OVERRIDE
Analogue of printf but writes result to the file.
TUINT32 m_Position
virtual TSIZE Tell() OVERRIDE
TUINT32 m_LastBufferSize
TUINT32 m_PrevBufferPos
TUINT32 m_RBufferPosition