mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
FileSystem improvements
* Added method 'FPrintf'. * Shifted indexes back by 2 if <GAMEDLL_S3 (Anything <S3 doesn't have the 2 FeatureFlags initialization methods which shifts everything past index 10 back by 2).
This commit is contained in:
parent
aa9e7f25ed
commit
9bf7660138
@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
typedef void* FileHandle_t;
|
typedef void* FileHandle_t;
|
||||||
|
#define FILESYSTEM_INVALID_HANDLE ( FileHandle_t )0
|
||||||
|
|
||||||
enum class SearchPathAdd_t : int
|
enum class SearchPathAdd_t : int
|
||||||
{
|
{
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include "filesystem/filesystem.h"
|
#include "filesystem/filesystem.h"
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
//
|
// Singleton FileSystem
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
CFileSystem_Stdio* FileSystem()
|
CFileSystem_Stdio* FileSystem()
|
||||||
{
|
{
|
||||||
@ -18,7 +18,7 @@ CFileSystem_Stdio* FileSystem()
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void IFileSystem::AddSearchPath(const char* pPath, const char* pPathID, SearchPathAdd_t addType)
|
void IFileSystem::AddSearchPath(const char* pPath, const char* pPathID, SearchPathAdd_t addType)
|
||||||
{
|
{
|
||||||
const int index = 12;
|
const int index = (12 - FS_VFTABLE_SHIFT);
|
||||||
CallVFunc<void>(index, this, pPath, pPathID, addType);
|
CallVFunc<void>(index, this, pPath, pPathID, addType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,10 +31,34 @@ void IFileSystem::AddSearchPath(const char* pPath, const char* pPathID, SearchPa
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool IFileSystem::RemoveSearchPath(const char* pPath, const char* pPathID)
|
bool IFileSystem::RemoveSearchPath(const char* pPath, const char* pPathID)
|
||||||
{
|
{
|
||||||
const int index = 13;
|
const int index = (13 - FS_VFTABLE_SHIFT);
|
||||||
return CallVFunc<bool>(index, this, pPath, pPathID);
|
return CallVFunc<bool>(index, this, pPath, pPathID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: print to file.
|
||||||
|
// Input : file -
|
||||||
|
// *pFormat -
|
||||||
|
// ... -
|
||||||
|
// Output : number of bytes written.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
int IFileSystem::FPrintf(FileHandle_t file, const char* pFormat, ...) FMTFUNCTION(3, 4)
|
||||||
|
{
|
||||||
|
const int index = (29 - FS_VFTABLE_SHIFT);
|
||||||
|
char buf[65560];
|
||||||
|
{/////////////////////////////
|
||||||
|
va_list args{};
|
||||||
|
va_start(args, pFormat);
|
||||||
|
|
||||||
|
vsnprintf(buf, sizeof(buf), pFormat, args);
|
||||||
|
|
||||||
|
buf[sizeof(buf) - 1] = '\0';
|
||||||
|
va_end(args);
|
||||||
|
}/////////////////////////////
|
||||||
|
|
||||||
|
return CallVFunc<int>(index, this, file, buf);
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: read file from cache.
|
// Purpose: read file from cache.
|
||||||
// Input : *pPath -
|
// Input : *pPath -
|
||||||
@ -43,7 +67,7 @@ bool IFileSystem::RemoveSearchPath(const char* pPath, const char* pPathID)
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool IFileSystem::ReadFromCache(const char* pPath, void* pResult)
|
bool IFileSystem::ReadFromCache(const char* pPath, void* pResult)
|
||||||
{
|
{
|
||||||
const int index = 76;
|
const int index = (76 - FS_VFTABLE_SHIFT);
|
||||||
return CallVFunc<bool>(index, this, pPath, pResult);
|
return CallVFunc<bool>(index, this, pPath, pResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,7 +78,7 @@ bool IFileSystem::ReadFromCache(const char* pPath, void* pResult)
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
VPKData_t* IFileSystem::MountVPK(const char* pPath)
|
VPKData_t* IFileSystem::MountVPK(const char* pPath)
|
||||||
{
|
{
|
||||||
const int index = 92;
|
const int index = (92 - FS_VFTABLE_SHIFT);
|
||||||
return CallVFunc<VPKData_t*>(index, this, pPath);
|
return CallVFunc<VPKData_t*>(index, this, pPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,11 +6,20 @@
|
|||||||
#define GAMEINFOPATH_TOKEN "|gameinfo_path|"
|
#define GAMEINFOPATH_TOKEN "|gameinfo_path|"
|
||||||
#define BASESOURCEPATHS_TOKEN "|all_source_engine_paths|"
|
#define BASESOURCEPATHS_TOKEN "|all_source_engine_paths|"
|
||||||
|
|
||||||
|
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) || defined (GAMEDLL_S2)
|
||||||
|
constexpr int FS_VFTABLE_SHIFT = 2;
|
||||||
|
#else
|
||||||
|
constexpr int FS_VFTABLE_SHIFT = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
class IFileSystem
|
class IFileSystem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void AddSearchPath(const char* pPath, const char* pPathID, SearchPathAdd_t addType);
|
void AddSearchPath(const char* pPath, const char* pPathID, SearchPathAdd_t addType);
|
||||||
bool RemoveSearchPath(const char* pPath, const char* pPathID);
|
bool RemoveSearchPath(const char* pPath, const char* pPathID);
|
||||||
|
|
||||||
|
int FPrintf(FileHandle_t file, const char* pFormat, ...) FMTFUNCTION(3, 4);
|
||||||
|
|
||||||
bool ReadFromCache(const char* pPath, void* pResult);
|
bool ReadFromCache(const char* pPath, void* pResult);
|
||||||
VPKData_t* MountVPK(const char* pVpkPath);
|
VPKData_t* MountVPK(const char* pVpkPath);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user