-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
14 changed files
with
596 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,9 @@ | |
*.lib | ||
*.lib.* | ||
*.exe.* | ||
bin | ||
bin-int | ||
act.exe | ||
|
||
# User-specific files | ||
*.rsuser | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
#include "TKernel/TFile.h" | ||
#include <catch2/catch_test_macros.hpp> | ||
#include <windows.h> | ||
#include <fstream> | ||
#include <direct.h> | ||
#include "TKernel/TDebug.h" | ||
#include "TKernel/Win/TNativeFileWin.h" | ||
|
||
TOSHI_NAMESPACE_USING | ||
|
||
TEST_CASE("Create File", "[TFile]") | ||
{ | ||
TFileManager* pFileManager = new TFileManager(); | ||
TFile::Create("Test.txt", TMODE_CREATE); | ||
TFile* f = TFile::Create("Test.txt", TMODE_CREATE); | ||
f->Destroy(); | ||
std::ifstream f2("Test.txt"); | ||
REQUIRE(f2.good()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,23 @@ | ||
#include <catch2/catch_session.hpp> | ||
#include "TApplication/TApplication.h" | ||
|
||
int main(int argc, char* argv[]) { | ||
TOSHI_NAMESPACE_USING | ||
|
||
int result = Catch::Session().run(argc, argv); | ||
class AApplication : public Toshi::TApplication | ||
{ | ||
}; | ||
|
||
static AApplication g_oTheApp; | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
int result; | ||
if (g_oTheApp.Create("UnitTests", argc, argv)) { | ||
//g_oTheApp.Execute(); | ||
result = Catch::Session().run(argc, argv); | ||
} | ||
|
||
g_oTheApp.Destroy(); | ||
|
||
return result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#pragma once | ||
#include "../TFile.h" | ||
|
||
#define BUFFER_SIZE 0x800 | ||
|
||
TOSHI_NAMESPACE_BEGIN | ||
|
||
class TOSHI_EXPORT TNativeFileSystem : public TFileSystem | ||
{ | ||
public: | ||
TNativeFileSystem(TPCCHAR a_pcName); | ||
|
||
virtual TFile* CreateFile(Toshi::TCString const& a_rFilename, TUINT a_uiMode) override; | ||
virtual void DestroyFile(TFile* a_pFile) override; | ||
virtual TBOOL RemoveFile(TCString const& a_rFilename) override; | ||
virtual TCString MakeInternalPath(const TCString& a_rsPath) override; | ||
|
||
private: | ||
HANDLE m_hFileSystem; // 0x1C | ||
}; | ||
|
||
class TOSHI_EXPORT TNativeFileManager : public TFileManager | ||
{ | ||
|
||
}; | ||
|
||
class TOSHI_EXPORT TNativeFile : public TFile | ||
{ | ||
friend class TNativeFileSystem; | ||
public: | ||
|
||
virtual TINT Read(TPVOID a_pBuffer, TINT a_iSize) override; | ||
virtual TINT Write(void const* a_pBuffer, TINT a_iSize) override; | ||
virtual TBOOL Seek(TINT a_iOffset, TSEEK a_eSeek) override; | ||
virtual TINT Tell() override { return m_iPosition; } | ||
virtual TINT GetSize() override; | ||
virtual TUINT64 GetDate() override; | ||
virtual TINT GetCChar() override; | ||
virtual TINT GetWChar() override; | ||
virtual TINT PutCChar(TCHAR a_cChar) override; | ||
virtual TINT PutWChar(TWCHAR a_wcChar) override; | ||
virtual TINT VCPrintf(TCHAR const* a_pFormat, va_list a_args) override; | ||
virtual TINT VWPrintf(TWCHAR const* a_pFormat, va_list a_args) override; | ||
|
||
protected: | ||
TNativeFile(TNativeFileSystem *a_pFileManager); | ||
virtual ~TNativeFile() = default; | ||
|
||
TBOOL Open(const TCString &a_rFileName, TUINT a_uiMode); | ||
void Close(); | ||
|
||
private: | ||
TINT ReadUnbuffered(TPVOID a_pBuffer, TINT a_iSize); | ||
TBOOL LoadBuffer(TINT a_iBufferPos); | ||
TINT FlushWriteBuffer(); | ||
|
||
private: | ||
HANDLE m_hFile; // 0x8 | ||
TINT m_iPosition; // 0xC | ||
TINT m_iBufferPosition; // 0x10 | ||
TINT m_iPrevBufferPos; // 0x14 | ||
TINT m_iLastBufferSize; // 0x18 | ||
TPVOID m_pBuffer; // 0x1C | ||
TPVOID m_pWriteBuffer; // 0x20 | ||
TINT m_iWriteBufferUsed; // 0x24 | ||
TBOOL m_bWriteBuffered; // 0x28 | ||
}; | ||
|
||
TOSHI_NAMESPACE_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.