mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Heavy FileSystem upgrades
Implement VFTable's to interface with engine (for the most part mapped out, only the new VPK methods needs further reversing). This exposes a good majority of the FileSystem implementation of the engine, to the SDK.
This commit is contained in:
parent
4cc0d085d4
commit
aa72579656
@ -1,3 +1,16 @@
|
||||
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose: An application framework
|
||||
//
|
||||
// $Revision: $
|
||||
// $NoKeywords: $
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef IAPPSYSTEM_H
|
||||
#define IAPPSYSTEM_H
|
||||
|
||||
#include <vpc/interfaces.h>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Specifies a module + interface name for initialization
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -8,7 +21,11 @@ struct AppSystemInfo_t
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Client systems are singleton objects in the client codebase responsible for
|
||||
// various tasks
|
||||
// The order in which the client systems appear in this list are the
|
||||
// order in which they are initialized and updated. They are shut down in
|
||||
// reverse order from which they are initialized.
|
||||
//-----------------------------------------------------------------------------
|
||||
enum InitReturnVal_t
|
||||
{
|
||||
@ -30,4 +47,33 @@ enum AppSystemTier_t
|
||||
|
||||
APP_SYSTEM_TIER_OTHER,
|
||||
};
|
||||
// NOTE: _purecall IAppSystem vtable
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
abstract_class IAppSystem
|
||||
{
|
||||
public:
|
||||
// Here's where the app systems get to learn about each other
|
||||
virtual bool Connect(CreateInterfaceFn factory) = 0;
|
||||
virtual void Disconnect() = 0;
|
||||
|
||||
// Here's where systems can access other interfaces implemented by this object
|
||||
// Returns NULL if it doesn't implement the requested interface
|
||||
virtual void* QueryInterface(const char* pInterfaceName) = 0;
|
||||
|
||||
// Init, shutdown
|
||||
virtual InitReturnVal_t Init() = 0;
|
||||
virtual void Shutdown() = 0;
|
||||
|
||||
// Returns all dependent libraries
|
||||
//virtual const AppSystemInfo_t* GetDependencies() { return NULL; }
|
||||
|
||||
// Returns the tier
|
||||
virtual AppSystemTier_t GetTier() = 0;
|
||||
|
||||
// Reconnect to a particular interface
|
||||
virtual void Reconnect(CreateInterfaceFn factory, const char* pInterfaceName) = 0;
|
||||
};
|
||||
|
||||
#endif // IAPPSYSTEM_H
|
@ -15,7 +15,7 @@
|
||||
#ifndef DEDICATED
|
||||
#include "game/client/enginesprite.h"
|
||||
#endif // !DEDICATED
|
||||
typedef int FileNameHandle_t; // 4 bytes in r5, void* originally.
|
||||
typedef int ModelFileNameHandle_t; // 4 bytes in r5, void* originally.
|
||||
|
||||
struct brushdata_t // !! UNCONFIRMED !!
|
||||
{
|
||||
@ -45,7 +45,7 @@ struct spritedata_t // !! UNCONFIRMED !!
|
||||
|
||||
struct model_t // !! CONFIRMED !!
|
||||
{
|
||||
FileNameHandle_t fnHandle;
|
||||
ModelFileNameHandle_t fnHandle;
|
||||
char szPathName[MAX_OSPATH];
|
||||
|
||||
int nLoadFlags; // mark loaded/not loaded
|
||||
|
@ -7,55 +7,6 @@
|
||||
#include "gameui/IConsole.h"
|
||||
#endif // !DEDICATED
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
// Purpose: reads data from memory
|
||||
// Input : *pOutput -
|
||||
// nSize -
|
||||
// hFile -
|
||||
// Output : lenght of read data
|
||||
//---------------------------------------------------------------------------------
|
||||
int CBaseFileSystem::Read(void* pOutput, int nSize, FileHandle_t hFile)
|
||||
{
|
||||
int index = 0;
|
||||
return CallVFunc<int>(index, this, pOutput, nSize, hFile);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
// Purpose: open file
|
||||
// Input : *pFileName -
|
||||
// *pOptions -
|
||||
// *pPathID -
|
||||
// unknown
|
||||
// Output : Handle to file on success, NULL on failure
|
||||
//---------------------------------------------------------------------------------
|
||||
FileHandle_t CBaseFileSystem::Open(const char* pFileName, const char* pOptions, const char* pPathID, int64_t unknown)
|
||||
{
|
||||
int index = 2;
|
||||
return CallVFunc<FileHandle_t>(index, this, pFileName, pOptions, pPathID, unknown);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
// Purpose: close file by handle
|
||||
// Input : file -
|
||||
//---------------------------------------------------------------------------------
|
||||
void CBaseFileSystem::Close(FileHandle_t file)
|
||||
{
|
||||
int index = 3;
|
||||
CallVFunc<void>(index, this, file);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
// Purpose: checks if file exists in all searchpaths and pak files
|
||||
// Input : *pFileName -
|
||||
// *pPathID -
|
||||
// Output : true if file exists, false otherwise
|
||||
//---------------------------------------------------------------------------------
|
||||
bool CBaseFileSystem::FileExists(const char* pFileName, const char* pPathID)
|
||||
{
|
||||
int index = 10;
|
||||
return CallVFunc<bool>(index, this, pFileName, pPathID);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
// Purpose: prints the output of the filesystem based on the warning level
|
||||
// Input : *this -
|
||||
|
@ -1,38 +1,41 @@
|
||||
#pragma once
|
||||
typedef void* FileHandle_t;
|
||||
#define FILESYSTEM_INVALID_HANDLE ( FileHandle_t )0
|
||||
#include "public/ifilesystem.h"
|
||||
|
||||
enum class SearchPathAdd_t : int
|
||||
{
|
||||
PATH_ADD_TO_HEAD, // First path searched
|
||||
PATH_ADD_TO_TAIL, // Last path searched
|
||||
PATH_ADD_TO_TAIL_ATINDEX, // First path searched
|
||||
};
|
||||
|
||||
enum class FileWarningLevel_t : int
|
||||
{
|
||||
FILESYSTEM_WARNING = -1, // A problem!
|
||||
FILESYSTEM_WARNING_QUIET = 0, // Don't print anything
|
||||
FILESYSTEM_WARNING_REPORTUNCLOSED, // On shutdown, report names of files left unclosed
|
||||
FILESYSTEM_WARNING_REPORTUSAGE, // Report number of times a file was opened, closed
|
||||
FILESYSTEM_WARNING_REPORTALLACCESSES, // Report all open/close events to console ( !slow! )
|
||||
FILESYSTEM_WARNING_REPORTALLACCESSES_READ, // Report all open/close/read events to the console ( !slower! )
|
||||
FILESYSTEM_WARNING_REPORTALLACCESSES_READWRITE, // Report all open/close/read/write events to the console ( !slower! )
|
||||
FILESYSTEM_WARNING_REPORTALLACCESSES_ASYNC // Report all open/close/read/write events and all async I/O file events to the console ( !slower(est)! )
|
||||
};
|
||||
|
||||
class CBaseFileSystem
|
||||
class CBaseFileSystem : public IFileSystem
|
||||
{
|
||||
public:
|
||||
int Read(void* pOutput, int nSize, FileHandle_t hFile);
|
||||
FileHandle_t Open(const char* pFileName, const char* pOptions, const char* pPathID, int64_t unknown);
|
||||
void Close(FileHandle_t file);
|
||||
bool FileExists(const char* pFileName, const char* pPathID);
|
||||
//--------------------------------------------------------
|
||||
// Purpose: Static methods used for hooking.
|
||||
//--------------------------------------------------------
|
||||
static void Warning(CBaseFileSystem* pFileSystem, FileWarningLevel_t level, const char* fmt, ...);
|
||||
static FileHandle_t VReadFromVPK(CBaseFileSystem* pVpk, FileHandle_t pResults, char* pszFilePath);
|
||||
static bool VReadFromCache(CBaseFileSystem* pFileSystem, char* pszFilePath, void* pResults);
|
||||
static void VAddSearchPath(CBaseFileSystem* pFileSystem, const char* pPath, const char* pPathID, SearchPathAdd_t addType);
|
||||
static bool VRemoveSearchPath(CBaseFileSystem* pFileSystem, const char* pPath, const char* pPathID);
|
||||
|
||||
protected:
|
||||
//----------------------------------------------------------------------------
|
||||
// Purpose: Functions implementing basic file system behavior.
|
||||
//----------------------------------------------------------------------------
|
||||
virtual FILE* FS_fopen(const char* filename, const char* options, unsigned flags, int64* size) = 0;
|
||||
virtual void FS_setbufsize(FILE* fp, unsigned nBytes) = 0;
|
||||
virtual void FS_fclose(FILE* fp) = 0;
|
||||
virtual void FS_fseek(FILE* fp, int64 pos, int seekType) = 0;
|
||||
virtual long FS_ftell(FILE* fp) = 0;
|
||||
virtual int FS_feof(FILE* fp) = 0;
|
||||
virtual size_t FS_fread(void* dest, size_t destSize, size_t size, FILE* fp) = 0;
|
||||
virtual size_t FS_fwrite(const void* src, size_t size, FILE* fp) = 0;
|
||||
virtual bool FS_setmode(FILE* fp, FileMode_t mode) = 0;
|
||||
virtual size_t FS_vfprintf(FILE* fp, const char* fmt, va_list list) = 0;
|
||||
virtual int FS_ferror(FILE* fp) = 0;
|
||||
virtual int FS_fflush(FILE* fp) = 0;
|
||||
virtual char* FS_fgets(char* dest, int destSize, FILE* fp) = 0;
|
||||
virtual int FS_stat(const char* path, struct _stat* buf, bool* pbLoadedFromSteamCache = NULL) = 0;
|
||||
virtual int FS_chmod(const char* path, int pmode) = 0;
|
||||
virtual HANDLE FS_FindFirstFile(const char* findname, WIN32_FIND_DATA* dat) = 0;
|
||||
virtual bool FS_FindNextFile(HANDLE handle, WIN32_FIND_DATA* dat) = 0;
|
||||
virtual bool FS_FindClose(HANDLE handle) = 0;
|
||||
virtual int FS_GetSectorSize(FILE*) = 0;
|
||||
};
|
||||
|
||||
/* ==== CBASEFILESYSTEM ================================================================================================================================================= */
|
||||
@ -78,7 +81,7 @@ class VBaseFileSystem : public IDetour
|
||||
p_CBaseFileSystem_AddSearchPath = g_GameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x44\x89\x4C\x24\x00\x48\x89\x4C\x24\x00\x55\x57"), "xxxx?xxxx?xx");
|
||||
p_CBaseFileSystem_RemoveSearchPath = g_GameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x40\x53\x55\x56\x57\x41\x54\x41\x56\x41\x57\x48\x81\xEC\x00\x00\x00\x00\xC6\x44\x24\x00\x00"), "xxxxxxxxxxxxxx????xxx??");
|
||||
|
||||
CBaseFileSystem_Warning = p_CBaseFileSystem_Warning.RCast<void(*)(CBaseFileSystem*, FileWarningLevel_t, const char*, ...)>(); /*4C 89 4C 24 20 C3 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 48*/
|
||||
CBaseFileSystem_Warning = p_CBaseFileSystem_Warning.RCast<void(*)(CBaseFileSystem*, FileWarningLevel_t, const char*, ...)>(); /*4C 89 4C 24 20 C3 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 48*/
|
||||
CBaseFileSystem_VLoadFromVPK = p_CBaseFileSystem_LoadFromVPK.RCast<FileHandle_t(*)(CBaseFileSystem*, FileHandle_t, char*)>(); /*48 89 5C 24 ?? 57 48 81 EC ?? ?? ?? ?? 49 8B C0 4C 8D 8C 24 ?? ?? ?? ??*/
|
||||
CBaseFileSystem_VLoadFromCache = p_CBaseFileSystem_LoadFromCache.RCast<bool(*)(CBaseFileSystem*, char*, void*)>(); /*40 53 48 81 EC ?? ?? ?? ?? 80 3D ?? ?? ?? ?? ?? 49 8B D8*/
|
||||
CBaseFileSystem_VAddSearchPath = p_CBaseFileSystem_AddSearchPath.RCast<void(*)(CBaseFileSystem*, const char*, const char*, SearchPathAdd_t)>(); /*44 89 4C 24 ?? 48 89 4C 24 ?? 55 57*/
|
||||
|
@ -7,79 +7,7 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
CFileSystem_Stdio* FileSystem()
|
||||
{
|
||||
return *g_pFullFileSystem;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: create the search path.
|
||||
// Input : *pPath -
|
||||
// *pPathID -
|
||||
// addType -
|
||||
//-----------------------------------------------------------------------------
|
||||
void IFileSystem::AddSearchPath(const char* pPath, const char* pPathID, SearchPathAdd_t addType)
|
||||
{
|
||||
const int index = (12 - FS_VFTABLE_SHIFT);
|
||||
CallVFunc<void>(index, this, pPath, pPathID, addType);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: removes the search path.
|
||||
// Input : *pPath -
|
||||
// *pPathID -
|
||||
// addType -
|
||||
// Output : true on success, false otherwise.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool IFileSystem::RemoveSearchPath(const char* pPath, const char* pPathID)
|
||||
{
|
||||
const int index = (13 - FS_VFTABLE_SHIFT);
|
||||
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.
|
||||
// Input : *pPath -
|
||||
// *pResult -
|
||||
// Output : true if exists, false otherwise.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool IFileSystem::ReadFromCache(const char* pPath, void* pResult)
|
||||
{
|
||||
const int index = (76 - FS_VFTABLE_SHIFT);
|
||||
return CallVFunc<bool>(index, this, pPath, pResult);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: mount specified VPK file (to access data).
|
||||
// Input : *pPath -
|
||||
// Output : *VPKData_t (information about mounted VPK file)
|
||||
//-----------------------------------------------------------------------------
|
||||
VPKData_t* IFileSystem::MountVPK(const char* pPath)
|
||||
{
|
||||
const int index = (92 - FS_VFTABLE_SHIFT);
|
||||
return CallVFunc<VPKData_t*>(index, this, pPath);
|
||||
return (*g_pFullFileSystem);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1,31 +1,33 @@
|
||||
#ifndef FILESYSTEM_H
|
||||
#define FILESYSTEM_H
|
||||
#include "vpklib/packedstore.h"
|
||||
|
||||
#include "public/ifilesystem.h"
|
||||
#include "public/ifile.h"
|
||||
#include "filesystem/basefilesystem.h"
|
||||
|
||||
#define GAMEINFOPATH_TOKEN "|gameinfo_path|"
|
||||
#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
|
||||
{
|
||||
public:
|
||||
void AddSearchPath(const char* pPath, const char* pPathID, SearchPathAdd_t addType);
|
||||
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);
|
||||
VPKData_t* MountVPK(const char* pVpkPath);
|
||||
};
|
||||
|
||||
class CFileSystem_Stdio : public IFileSystem, public CBaseFileSystem
|
||||
class CFileSystem_Stdio : public CBaseFileSystem
|
||||
{
|
||||
protected:
|
||||
// implementation of CBaseFileSystem virtual functions
|
||||
virtual FILE* FS_fopen(const char* filename, const char* options, unsigned flags, int64* size) = 0;
|
||||
virtual void FS_setbufsize(FILE* fp, unsigned nBytes) = 0;
|
||||
virtual void FS_fclose(FILE* fp) = 0;
|
||||
virtual void FS_fseek(FILE* fp, int64 pos, int seekType) = 0;
|
||||
virtual long FS_ftell(FILE* fp) = 0;
|
||||
virtual int FS_feof(FILE* fp) = 0;
|
||||
virtual size_t FS_fread(void* dest, size_t destSize, size_t size, FILE* fp) = 0;
|
||||
virtual size_t FS_fwrite(const void* src, size_t size, FILE* fp) = 0;
|
||||
virtual bool FS_setmode(FILE* fp, FileMode_t mode) = 0;
|
||||
virtual size_t FS_vfprintf(FILE* fp, const char* fmt, va_list list) = 0;
|
||||
virtual int FS_ferror(FILE* fp) = 0;
|
||||
virtual int FS_fflush(FILE* fp) = 0;
|
||||
virtual char* FS_fgets(char* dest, int destSize, FILE* fp) = 0;
|
||||
virtual int FS_stat(const char* path, struct _stat* buf, bool* pbLoadedFromSteamCache = NULL) = 0;
|
||||
virtual int FS_chmod(const char* path, int pmode) = 0;
|
||||
virtual HANDLE FS_FindFirstFile(const char* findname, WIN32_FIND_DATA* dat) = 0;
|
||||
virtual bool FS_FindNextFile(HANDLE handle, WIN32_FIND_DATA* dat) = 0;
|
||||
virtual bool FS_FindClose(HANDLE handle) = 0;
|
||||
virtual int FS_GetSectorSize(FILE*) = 0;
|
||||
};
|
||||
|
||||
extern CFileSystem_Stdio** g_pFullFileSystem; // Ptr to g_pFileSystem_Stdio.
|
||||
|
63
r5dev/public/ifile.h
Normal file
63
r5dev/public/ifile.h
Normal file
@ -0,0 +1,63 @@
|
||||
#ifndef IFILE_H
|
||||
#define IFILE_H
|
||||
|
||||
#include "public/ifilesystem.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Per-file worker classes
|
||||
//-----------------------------------------------------------------------------
|
||||
abstract_class CStdFilesystemFile
|
||||
{
|
||||
public:
|
||||
virtual ~CStdFilesystemFile() {}
|
||||
virtual void FS_setbufsize(unsigned nBytes) = 0;
|
||||
virtual void FS_fclose() = 0;
|
||||
virtual void FS_fseek(int64 pos, int seekType) = 0;
|
||||
virtual long FS_ftell() = 0;
|
||||
virtual int FS_feof() = 0;
|
||||
virtual size_t FS_fread(void* dest, size_t destSize, size_t size) = 0;
|
||||
virtual size_t FS_fwrite(const void* src, size_t size) = 0;
|
||||
virtual bool FS_setmode(FileMode_t mode) = 0;
|
||||
virtual size_t FS_vfprintf(const char* fmt, va_list list) = 0;
|
||||
virtual int FS_ferror() = 0;
|
||||
virtual int FS_fflush() = 0;
|
||||
virtual char* FS_fgets(char* dest, int destSize) = 0;
|
||||
virtual int FS_GetSectorSize() { return 1; }
|
||||
};
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
||||
class CStdioFile : public CStdFilesystemFile
|
||||
{
|
||||
public:
|
||||
/* // [ !!! IMPLEMENTED IN ENGINE !!! ]
|
||||
static CStdioFile* FS_fopen(const char* filename, const char* options, int64* size);
|
||||
|
||||
virtual void FS_setbufsize(unsigned nBytes);
|
||||
virtual void FS_fclose();
|
||||
virtual void FS_fseek(int64 pos, int seekType);
|
||||
virtual long FS_ftell();
|
||||
virtual int FS_feof();
|
||||
virtual size_t FS_fread(void* dest, size_t destSize, size_t size);
|
||||
virtual size_t FS_fwrite(const void* src, size_t size);
|
||||
virtual bool FS_setmode(FileMode_t mode);
|
||||
virtual size_t FS_vfprintf(const char* fmt, va_list list);
|
||||
virtual int FS_ferror();
|
||||
virtual int FS_fflush();
|
||||
virtual char* FS_fgets(char* dest, int destSize);*/
|
||||
|
||||
#ifdef POSIX
|
||||
static CUtlMap< ino_t, CThreadMutex* > m_LockedFDMap;
|
||||
static CThreadMutex m_MutexLockedFD;
|
||||
#endif
|
||||
private:
|
||||
CStdioFile(FILE* pFile, bool bWriteable)
|
||||
: m_pFile(pFile), m_bWriteable(bWriteable)
|
||||
{
|
||||
}
|
||||
|
||||
FILE* m_pFile;
|
||||
bool m_bWriteable;
|
||||
};
|
||||
|
||||
#endif // IFILE_H
|
437
r5dev/public/ifilesystem.h
Normal file
437
r5dev/public/ifilesystem.h
Normal file
@ -0,0 +1,437 @@
|
||||
#ifndef IFILESYSTEM_H
|
||||
#define IFILESYSTEM_H
|
||||
|
||||
#include <tier0/annotations.h>
|
||||
#include <tier0/threadtools.h>
|
||||
#include <appframework/iappsystem.h>
|
||||
#include <vpc/keyvalues.h>
|
||||
#include "vpc/interfaces.h"
|
||||
#include <vpklib/packedstore.h>
|
||||
|
||||
typedef void* FileHandle_t;
|
||||
typedef void* FileNameHandle_t; // !TODO: Check if this is 4 or 8 bytes (model_t was 4 bytes in mem).
|
||||
typedef void* FileCacheHandle_t;
|
||||
typedef int FileFindHandle_t;
|
||||
|
||||
#define FILESYSTEM_INVALID_HANDLE ( FileHandle_t )0
|
||||
|
||||
#define GAMEINFOPATH_TOKEN "|gameinfo_path|"
|
||||
#define BASESOURCEPATHS_TOKEN "|all_source_engine_paths|"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Structures used by the interface
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
struct FileSystemStatistics
|
||||
{
|
||||
CInterlockedUInt nReads,
|
||||
nWrites,
|
||||
nBytesRead,
|
||||
nBytesWritten,
|
||||
nSeeks;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// File system allocation functions. Client must free on failure
|
||||
//-----------------------------------------------------------------------------
|
||||
typedef void* (*FSAllocFunc_t)(const char* pszFilename, unsigned nBytes);
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Used to display dirty disk error functions
|
||||
//-----------------------------------------------------------------------------
|
||||
typedef void (*FSDirtyDiskReportFunc_t)();
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Used for FileSystem logging
|
||||
//-----------------------------------------------------------------------------
|
||||
typedef void (*FileSystemLoggingFunc_t)(const char* fileName, const char* accessType);
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Asynchronous support types
|
||||
//-----------------------------------------------------------------------------
|
||||
DECLARE_POINTER_HANDLE(FSAsyncControl_t);
|
||||
DECLARE_POINTER_HANDLE(FSAsyncFile_t);
|
||||
const FSAsyncFile_t FS_INVALID_ASYNC_FILE = (FSAsyncFile_t)(0x0000ffff);
|
||||
|
||||
enum FilesystemMountRetval_t
|
||||
{
|
||||
FILESYSTEM_MOUNT_OK = 0,
|
||||
FILESYSTEM_MOUNT_FAILED,
|
||||
};
|
||||
|
||||
// search path filtering
|
||||
enum PathTypeFilter_t
|
||||
{
|
||||
FILTER_NONE = 0, // no filtering, all search path types match
|
||||
FILTER_CULLPACK = 1, // pack based search paths are culled (maps and zips)
|
||||
FILTER_CULLNONPACK = 2, // non-pack based search paths are culled
|
||||
FILTER_CULLLOCALIZED = 3, // Ignore localized paths, assumes CULLNONPACK
|
||||
FILTER_CULLLOCALIZED_ANY = 4, // Ignore any localized paths
|
||||
};
|
||||
|
||||
// search path querying (bit flags)
|
||||
enum
|
||||
{
|
||||
PATH_IS_NORMAL = 0x00, // normal path, not pack based
|
||||
PATH_IS_PACKFILE = 0x01, // path is a pack file
|
||||
PATH_IS_MAPPACKFILE = 0x02, // path is a map pack file
|
||||
PATH_IS_DVDDEV = 0x04, // path is the dvddev cache
|
||||
};
|
||||
typedef uint32 PathTypeQuery_t;
|
||||
|
||||
#define IS_PACKFILE( n ) ( n & ( PATH_IS_PACKFILE | PATH_IS_MAPPACKFILE ) )
|
||||
#define IS_DVDDEV( n ) ( n & PATH_IS_DVDDEV )
|
||||
|
||||
enum class SearchPathAdd_t : int
|
||||
{
|
||||
PATH_ADD_TO_HEAD, // First path searched
|
||||
PATH_ADD_TO_TAIL, // Last path searched
|
||||
PATH_ADD_TO_TAIL_ATINDEX, // First path searched
|
||||
};
|
||||
|
||||
enum class FileWarningLevel_t : int
|
||||
{
|
||||
FILESYSTEM_WARNING = -1, // A problem!
|
||||
FILESYSTEM_WARNING_QUIET = 0, // Don't print anything
|
||||
FILESYSTEM_WARNING_REPORTUNCLOSED, // On shutdown, report names of files left unclosed
|
||||
FILESYSTEM_WARNING_REPORTUSAGE, // Report number of times a file was opened, closed
|
||||
FILESYSTEM_WARNING_REPORTALLACCESSES, // Report all open/close events to console ( !slow! )
|
||||
FILESYSTEM_WARNING_REPORTALLACCESSES_READ, // Report all open/close/read events to the console ( !slower! )
|
||||
FILESYSTEM_WARNING_REPORTALLACCESSES_READWRITE, // Report all open/close/read/write events to the console ( !slower! )
|
||||
FILESYSTEM_WARNING_REPORTALLACCESSES_ASYNC // Report all open/close/read/write events and all async I/O file events to the console ( !slower(est)! )
|
||||
};
|
||||
|
||||
#define FILESYSTEM_MAX_SEARCH_PATHS 128
|
||||
|
||||
enum FileMode_t
|
||||
{
|
||||
FM_BINARY,
|
||||
FM_TEXT
|
||||
};
|
||||
|
||||
enum FileType_t
|
||||
{
|
||||
FT_NORMAL,
|
||||
FT_PACK_BINARY,
|
||||
FT_PACK_TEXT,
|
||||
FT_MEMORY_BINARY,
|
||||
FT_MEMORY_TEXT
|
||||
};
|
||||
|
||||
enum FileSystemSeek_t
|
||||
{
|
||||
FILESYSTEM_SEEK_HEAD = SEEK_SET,
|
||||
FILESYSTEM_SEEK_CURRENT = SEEK_CUR,
|
||||
FILESYSTEM_SEEK_TAIL = SEEK_END,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
FILESYSTEM_INVALID_FIND_HANDLE = -1
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
abstract_class IBaseFileSystem
|
||||
{
|
||||
public:
|
||||
virtual int Read(void* pOutput, int size, FileHandle_t file) = 0;
|
||||
virtual int Write(void const* pInput, int size, FileHandle_t file) = 0;
|
||||
|
||||
// if pathID is NULL, all paths will be searched for the file
|
||||
virtual FileHandle_t Open(const char* pFileName, const char* pOptions, const char* pPathID, int64_t unknown = 0) = 0;
|
||||
virtual void Close(FileHandle_t file) = 0;
|
||||
|
||||
virtual void Seek(FileHandle_t file, int pos, FileSystemSeek_t seekType) = 0;
|
||||
virtual unsigned int Tell(FileHandle_t file) = 0;
|
||||
virtual unsigned int Size(const char* pFileName, const char* pPathID = 0) = 0;
|
||||
virtual unsigned int Size(FileHandle_t file) = 0;
|
||||
|
||||
virtual void Flush(FileHandle_t file) = 0;
|
||||
virtual bool Precache(const char* pFileName, const char* pPathID = 0) = 0;
|
||||
|
||||
virtual bool FileExists(const char* pFileName, const char* pPathID = 0) = 0;
|
||||
virtual bool IsFileWritable(char const* pFileName, const char* pPathID = 0) = 0;
|
||||
virtual bool SetFileWritable(char const* pFileName, bool writable, const char* pPathID = 0) = 0;
|
||||
|
||||
virtual long GetFileTime(const char* pFileName, const char* pPathID = 0) = 0;
|
||||
|
||||
//--------------------------------------------------------
|
||||
// Reads/writes files to utlbuffers. Use this for optimal read performance when doing open/read/close.
|
||||
//--------------------------------------------------------
|
||||
virtual bool ReadFile(const char* pFileName, const char* pPath, void* buf, int nMaxBytes = 0, int nStartingByte = 0, FSAllocFunc_t pfnAlloc = NULL) = 0; // !FIXME [AMOS]: buf = CUtlBuffer&!
|
||||
virtual bool WriteFile(const char* pFileName, const char* pPath, void* buf) = 0; // !FIXME [AMOS]: buf = CUtlBuffer&!
|
||||
virtual bool UnzipFile(const char* pFileName, const char* pPath, const char* pDestination) = 0;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
abstract_class IFileSystem : public IAppSystem, public IBaseFileSystem
|
||||
{
|
||||
public:
|
||||
virtual ~IFileSystem() = 0;
|
||||
|
||||
//--------------------------------------------------------
|
||||
// IAppSystem methods
|
||||
//--------------------------------------------------------
|
||||
virtual bool Connect(CreateInterfaceFn factory) = 0;
|
||||
virtual void Disconnect() = 0;
|
||||
virtual void* QueryInterface(const char* pInterfaceName) = 0;
|
||||
virtual InitReturnVal_t Init() = 0;
|
||||
virtual void Shutdown() = 0;
|
||||
virtual AppSystemTier_t GetTier() = 0;
|
||||
virtual void Reconnect(CreateInterfaceFn factory, const char* pInterfaceName) = 0;
|
||||
|
||||
//--------------------------------------------------------
|
||||
virtual bool IsSteam() const = 0;
|
||||
|
||||
// Supplying an extra app id will mount this app in addition
|
||||
// to the one specified in the environment variable "steamappid"
|
||||
//
|
||||
// If nExtraAppId is < -1, then it will mount that app ID only.
|
||||
// (Was needed by the dedicated server b/c the "SteamAppId" env var only gets passed to steam.dll
|
||||
// at load time, so the dedicated couldn't pass it in that way).
|
||||
virtual FilesystemMountRetval_t MountSteamContent(int nExtraAppId = -1) = 0;
|
||||
|
||||
#if !defined (GAMEDLL_S0) || !defined (GAMEDLL_S1) || !defined (GAMEDLL_S2)
|
||||
virtual bool InitFeatureFlags() = 0;
|
||||
virtual bool InitFeatureFlags(const char* pszFlagSetFile) = 0;
|
||||
#endif // !GAMEDLL_S0 || !GAMEDLL_S1 || GAMEDLL_S2
|
||||
|
||||
virtual void AddSearchPath(const char* pPath, const char* pPathID, SearchPathAdd_t addType) = 0;
|
||||
virtual bool RemoveSearchPath(const char* pPath, const char* pPathID) = 0;
|
||||
virtual void RemoveAllSearchPaths(void) = 0; // Remove all search paths (including write path?)
|
||||
virtual void RemoveSearchPaths(const char* szPathID) = 0; // Remove search paths associated with a given pathID
|
||||
// This is for optimization. If you mark a path ID as "by request only", then files inside it
|
||||
// will only be accessed if the path ID is specifically requested. Otherwise, it will be ignored.
|
||||
// If there are currently no search paths with the specified path ID, then it will still
|
||||
// remember it in case you add search paths with this path ID.
|
||||
virtual void MarkPathIDByRequestOnly(const char* pPathID, bool bRequestOnly) = 0;
|
||||
// converts a partial path into a full path
|
||||
virtual const char* RelativePathToFullPath(const char* pFileName, const char* pPathID, char* pLocalPath, int localPathBufferSize, PathTypeFilter_t pathFilter = FILTER_NONE, PathTypeQuery_t* pPathType = NULL) = 0;
|
||||
#if IsGameConsole()
|
||||
// Given a relative path, gets the PACK file that contained this file and its offset and size. Can be used to prefetch a file to a HDD for caching reason.
|
||||
virtual bool GetPackFileInfoFromRelativePath(const char* pFileName, const char* pPathID, char* pPackPath, int nPackPathBufferSize, int64& nPosition, int64& nLength) = 0;
|
||||
#endif
|
||||
// Returns the search path, each path is separated by ;s. Returns the length of the string returned
|
||||
virtual int GetSearchPath(const char* pathID, bool bGetPackFiles, char* pPath, int nMaxLen) = 0;
|
||||
virtual bool AddPackFile(const char* fullpath, const char* pathID) = 0; // interface for custom pack files > 4Gb
|
||||
|
||||
//--------------------------------------------------------
|
||||
// File manipulation operations
|
||||
//--------------------------------------------------------
|
||||
virtual void RemoveFile(char const* pRelativePath, const char* pathID = 0) = 0; // Deletes a file (on the WritePath)
|
||||
virtual bool RenameFile(char const* pOldPath, char const* pNewPath, const char* pathID = 0) = 0; // Renames a file (on the WritePath)
|
||||
virtual void CreateDirHierarchy(const char* path, const char* pathID = 0) = 0; // create a local directory structure
|
||||
virtual bool IsDirectory(const char* pFileName, const char* pathID = 0) = 0; // File I/O and info
|
||||
virtual void FileTimeToString(char* pStrip, int maxCharsIncludingTerminator, long fileTime) = 0;
|
||||
|
||||
//--------------------------------------------------------
|
||||
// Open file operations
|
||||
//--------------------------------------------------------
|
||||
|
||||
virtual void SetBufferSize(FileHandle_t file, unsigned nBytes) = 0;
|
||||
virtual bool IsOk(FileHandle_t file) = 0;
|
||||
virtual bool EndOfFile(FileHandle_t file) = 0;
|
||||
virtual char* ReadLine(char* pOutput, int maxChars, FileHandle_t file) = 0;
|
||||
#if ! defined(SWIG)
|
||||
// Don't let SWIG see the PRINTF_FORMAT_STRING attribute or it will complain.
|
||||
virtual int FPrintf(FileHandle_t file, PRINTF_FORMAT_STRING const char* pFormat, ...) FMTFUNCTION(3, 4) = 0;
|
||||
#else
|
||||
virtual int FPrintf(FileHandle_t file, const char* pFormat, ...) FMTFUNCTION(3, 4) = 0;
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------
|
||||
// Dynamic library operations
|
||||
//--------------------------------------------------------
|
||||
// load/unload modules
|
||||
virtual CSysModule* LoadModule(const char* pFileName, const char* pPathID = 0, bool bValidatedDllOnly = true) = 0;
|
||||
virtual void UnloadModule(CSysModule* pModule) = 0;
|
||||
|
||||
//--------------------------------------------------------
|
||||
// File searching operations
|
||||
//--------------------------------------------------------
|
||||
// FindFirst/FindNext. Also see FindFirstEx.
|
||||
virtual const char* FindFirst(const char* pWildCard, FileFindHandle_t* pHandle) = 0;
|
||||
virtual const char* FindNext(FileFindHandle_t handle) = 0;
|
||||
virtual bool FindIsDirectory(FileFindHandle_t handle) = 0;
|
||||
virtual void FindClose(FileFindHandle_t handle) = 0;
|
||||
|
||||
// Same as FindFirst, but you can filter by path ID, which can make it faster.
|
||||
virtual const char* FindFirstEx(
|
||||
const char* pWildCard,
|
||||
const char* pPathID,
|
||||
FileFindHandle_t* pHandle
|
||||
) = 0;
|
||||
|
||||
// Searches for a file in all paths and results absolute path names for the file, works in pack files (zip and vpk) too
|
||||
// Lets you search for something like sound/sound.cache and get a list of every sound cache
|
||||
virtual void FindFileAbsoluteList(void* outAbsolutePathNames, const char* pWildCard, const char* pPathID) = 0; // !TODO: First param = 'CUtlVector< CUtlString >&'.
|
||||
|
||||
//--------------------------------------------------------
|
||||
// File name and directory operations
|
||||
//--------------------------------------------------------
|
||||
|
||||
// FIXME: This method is obsolete! Use RelativePathToFullPath instead!
|
||||
// converts a partial path into a full path
|
||||
virtual const char* GetLocalPath(const char* pFileName, char* pLocalPath, int localPathBufferSize) = 0;
|
||||
|
||||
// Returns true on success ( based on current list of search paths, otherwise false if
|
||||
// it can't be resolved )
|
||||
virtual bool FullPathToRelativePath(const char* pFullpath, char* pRelative, int maxlen) = 0;
|
||||
|
||||
// Gets the current working directory
|
||||
virtual bool GetCurrentDirectory(char* pDirectory, int maxlen) = 0;
|
||||
|
||||
//--------------------------------------------------------
|
||||
// Filename dictionary operations
|
||||
//--------------------------------------------------------
|
||||
|
||||
virtual FileNameHandle_t FindOrAddFileName(char const* pFileName) = 0;
|
||||
virtual bool String(const FileNameHandle_t& handle, char* buf, int buflen) = 0;
|
||||
|
||||
//--------------------------------------------------------
|
||||
// Asynchronous file operations
|
||||
//--------------------------------------------------------
|
||||
|
||||
//--------------- [ !!! AMOS: !!! ALL ASYNC METHODS ARE UNIMPLEMENTED !!! PURECALL !!! ] ---------------//
|
||||
//------------------------------------
|
||||
// Global operations
|
||||
//------------------------------------
|
||||
virtual void PureCall0() = 0;
|
||||
virtual void PureCall1() = 0;
|
||||
virtual void PureCall2() = 0;
|
||||
virtual void PureCall3() = 0;
|
||||
virtual void PureCall4() = 0;
|
||||
virtual void PureCall5() = 0;
|
||||
|
||||
//--------------------------------------------------------
|
||||
// Debugging operations
|
||||
//--------------------------------------------------------
|
||||
|
||||
// Dump to printf/OutputDebugString the list of files that have not been closed
|
||||
virtual void PrintOpenedFiles(void) = 0;
|
||||
virtual void PrintSearchPaths(void) = 0;
|
||||
|
||||
// output
|
||||
virtual void SetWarningFunc(void (*pfnWarning)(const char* fmt, ...)) = 0;
|
||||
virtual void SetWarningLevel(FileWarningLevel_t level) = 0;
|
||||
virtual void AddLoggingFunc(void (*pfnLogFunc)(const char* fileName, const char* accessType)) = 0;
|
||||
virtual void RemoveLoggingFunc(FileSystemLoggingFunc_t logFunc) = 0;
|
||||
|
||||
virtual __int64 __fastcall sub_14038C240(__int64 a1) = 0;
|
||||
virtual __int64 __fastcall sub_14038C380(__int64 a1) = 0;
|
||||
virtual __int64 __fastcall sub_14038C400(__int64 a1, __int64 a2) = 0;
|
||||
|
||||
// Returns the file system statistics retreived by the implementation. Returns NULL if not supported.
|
||||
virtual const FileSystemStatistics* GetFilesystemStatistics() = 0;
|
||||
|
||||
//--------------------------------------------------------
|
||||
// Start of new functions after Lost Coast release (7/05)
|
||||
//--------------------------------------------------------
|
||||
|
||||
virtual FileHandle_t OpenEx(const char* pFileName, const char* pOptions, unsigned flags = 0, const char* pathID = 0, char** ppszResolvedFilename = NULL) = 0;
|
||||
|
||||
// Extended version of read provides more context to allow for more optimal reading
|
||||
virtual int ReadEx(void* pOutput, int sizeDest, int size, FileHandle_t file) = 0;
|
||||
virtual int ReadFileEx(const char* pFileName, const char* pPath, void** ppBuf, bool bNullTerminate = false, bool bOptimalAlloc = false, int nMaxBytes = 0, int nStartingByte = 0, FSAllocFunc_t pfnAlloc = NULL) = 0;
|
||||
|
||||
virtual FileNameHandle_t FindFileName(char const* pFileName) = 0;
|
||||
|
||||
#if defined( TRACK_BLOCKING_IO )
|
||||
virtual void EnableBlockingFileAccessTracking(bool state) = 0;
|
||||
virtual bool IsBlockingFileAccessEnabled() const = 0;
|
||||
|
||||
virtual IBlockingFileItemList* RetrieveBlockingFileAccessInfo() = 0;
|
||||
#endif
|
||||
|
||||
virtual void SetupPreloadData() = 0;
|
||||
virtual void DiscardPreloadData() = 0;
|
||||
|
||||
// Fixme, we could do these via a string embedded into the compiled data, etc...
|
||||
enum KeyValuesPreloadType_t
|
||||
{
|
||||
TYPE_VMT,
|
||||
TYPE_SOUNDEMITTER,
|
||||
TYPE_SOUNDSCAPE,
|
||||
TYPE_SOUNDOPERATORS,
|
||||
NUM_PRELOAD_TYPES
|
||||
};
|
||||
|
||||
// If the "PreloadedData" hasn't been purged, then this'll try and instance the KeyValues using the fast path of compiled keyvalues loaded during startup.
|
||||
// Otherwise, it'll just fall through to the regular KeyValues loading routines
|
||||
virtual KeyValues* LoadKeyValues(KeyValuesPreloadType_t type, char const* filename, char const* pPathID = 0) = 0;
|
||||
virtual bool LoadKeyValues(KeyValues& head, KeyValuesPreloadType_t type, char const* filename, char const* pPathID = 0) = 0;
|
||||
|
||||
virtual bool GetFileTypeForFullPath(char const* pFullPath, wchar_t* buf, size_t bufSizeInBytes) = 0;
|
||||
|
||||
//--------------------------------------------------------
|
||||
//--------------------------------------------------------
|
||||
virtual bool ReadToBuffer(FileHandle_t hFile, void* buf, int nMaxBytes = 0, FSAllocFunc_t pfnAlloc = NULL) = 0; // !TODO: buf = 'CUtlBuffer&'
|
||||
|
||||
//--------------------------------------------------------
|
||||
// Optimal IO operations
|
||||
//--------------------------------------------------------
|
||||
virtual bool GetOptimalIOConstraints(FileHandle_t hFile, unsigned* pOffsetAlign, unsigned* pSizeAlign, unsigned* pBufferAlign) = 0;
|
||||
virtual void* AllocOptimalReadBuffer(FileHandle_t hFile, unsigned nSize = 0, unsigned nOffset = 0) = 0;
|
||||
virtual void FreeOptimalReadBuffer(void*) = 0;
|
||||
|
||||
|
||||
virtual bool __fastcall sub_140383E00(__int64 a2) = 0;
|
||||
virtual bool sub_1403836A0() = 0;
|
||||
virtual __int64 __fastcall sub_140384310(int a1) = 0;
|
||||
virtual __int64 __fastcall sub_140383820(int a1) = 0;
|
||||
|
||||
|
||||
//--------------------------------------------------------
|
||||
// Cache/VPK operations
|
||||
//--------------------------------------------------------
|
||||
virtual bool ReadFromCache(const char* pPath, void* pResult) = 0;
|
||||
|
||||
virtual bool __fastcall sub_14037FFA0(__int64 a1, unsigned int a2, __int64 a3) = 0;
|
||||
|
||||
virtual void SetVPKCacheModeClient() = 0; // g_nVPKCacheMode = 1;
|
||||
virtual void SetVPKCacheModeServer() = 0; // g_nVPKCacheMode = 2;
|
||||
virtual bool IsVPKCacheEnabled() = 0; // g_nVPKCacheMode != 0;
|
||||
|
||||
virtual __int64 __fastcall PrecacheTaskItem(__int64 a1) = 0;
|
||||
|
||||
virtual void sub_1403800A0() = 0;
|
||||
virtual void __fastcall sub_140380100(__int64 a1) = 0;
|
||||
virtual void __fastcall sub_140380230(char a2) = 0;
|
||||
virtual void* __fastcall sub_1403801F0(const void* a1, unsigned int a2) = 0;
|
||||
virtual void __fastcall sub_140380220(__int64 a1) = 0;
|
||||
virtual bool sub_140380070() = 0;
|
||||
virtual char __fastcall sub_1403836D0(int a1, char* a2, unsigned int a3) = 0;
|
||||
virtual __int64 __fastcall sub_140383840(unsigned int a1, __int64 a2, char* a3, unsigned int BufferCount) = 0;
|
||||
virtual const char** __fastcall sub_140383760(unsigned int a1) = 0;
|
||||
virtual __int64 __fastcall sub_140383A20(const char* a1) = 0;
|
||||
|
||||
virtual VPKData_t* MountVPKFile(const char* pVpkPath) = 0;
|
||||
virtual const char* UnmountVPKFile(const char* pBasename) = 0;
|
||||
|
||||
virtual void __fastcall sub_140383370() = 0;
|
||||
virtual void __fastcall sub_140383560() = 0;
|
||||
|
||||
virtual unsigned __int64 __fastcall PnpCtxRegQueryInfoKey(__int64 a1, char* a2, unsigned int* a3, unsigned __int64 a4, unsigned __int64 a5, void(__fastcall* a6)(unsigned __int64)) = 0;
|
||||
virtual char* sub_1403842B0() = 0;
|
||||
virtual __int64 __fastcall sub_1403842C0(__int64 a1, unsigned int a2, __int64 a3) = 0;
|
||||
|
||||
virtual char __fastcall LoadMainVPK(const char* pszVPKFile) = 0;
|
||||
|
||||
virtual __int64 sub_140380080() = 0;
|
||||
virtual char __fastcall sub_14038B530(const char* a1, unsigned __int8* a2, char* a3, __int64 Count) = 0;
|
||||
virtual __int64 __fastcall sub_14038C830(unsigned __int16* a1) = 0;
|
||||
virtual __int64 __fastcall sub_140388360(char* a1, __int64 a2) = 0;
|
||||
virtual __int64 __fastcall sub_140384C60(char* a1, unsigned __int64 a2) = 0;
|
||||
virtual void __fastcall sub_140382A80() = 0;
|
||||
virtual __int64 __fastcall sub_14038CC90(int a1, unsigned int a2, __int64 a3, __int64 a4) = 0;
|
||||
virtual __int64 __fastcall UserMathErrorFunction() = 0;
|
||||
};
|
||||
|
||||
#endif // IFILESYSTEM_H
|
116
r5dev/tier0/annotations.h
Normal file
116
r5dev/tier0/annotations.h
Normal file
@ -0,0 +1,116 @@
|
||||
#ifndef ANALYSIS_ANNOTATIONS_H
|
||||
#define ANALYSIS_ANNOTATIONS_H
|
||||
|
||||
#if _MSC_VER >= 1600 // VS 2010 and above.
|
||||
//-----------------------------------------------------------------------------
|
||||
// Upgrading important helpful warnings to errors
|
||||
//-----------------------------------------------------------------------------
|
||||
#pragma warning(error : 4789 ) // warning C4789: destination of memory copy is too small
|
||||
|
||||
// Suppress some code analysis warnings
|
||||
#ifdef _PREFAST_
|
||||
// Include the annotation header file.
|
||||
#include <sal.h>
|
||||
|
||||
// /Analyze warnings can only be suppressed when using a compiler that supports them, which VS 2010
|
||||
// Professional does not.
|
||||
|
||||
// We don't care about these warnings because they are bugs that can only occur during resource
|
||||
// exhaustion or other unexpected API failure, which we are nowhere near being able to handle.
|
||||
#pragma warning(disable : 6308) // warning C6308: 'realloc' might return null pointer: assigning null pointer to 's_ppTestCases', which is passed as an argument to 'realloc', will cause the original memory block to be leaked
|
||||
#pragma warning(disable : 6255) // warning C6255: _alloca indicates failure by raising a stack overflow exception. Consider using _malloca instead
|
||||
#pragma warning(disable : 6387) // warning C6387: 'argument 1' might be '0': this does not adhere to the specification for the function 'GetProcAddress'
|
||||
#pragma warning(disable : 6309) // warning C6309: Argument '1' is null: this does not adhere to function specification of 'GetProcAddress'
|
||||
#pragma warning(disable : 6011) // warning C6011: Dereferencing NULL pointer 'm_ppTestCases'
|
||||
#pragma warning(disable : 6211) // warning C6211: Leaking memory 'newKeyValue' due to an exception. Consider using a local catch block to clean up memory
|
||||
#pragma warning(disable : 6031) // warning C6031: Return value ignored: '_getcwd'
|
||||
|
||||
// These warnings are because /analyze doesn't like our use of constants, especially things like IsPC()
|
||||
#pragma warning(disable : 6326) // warning C6326: Potential comparison of a constant with another constant
|
||||
#pragma warning(disable : 6239) // warning C6239: (<non-zero constant> && <expression>) always evaluates to the result of <expression>. Did you intend to use the bitwise-and operator?
|
||||
#pragma warning(disable : 6285) // warning C6285: (<non-zero constant> || <non-zero constant>) is always a non-zero constant. Did you intend to use the bitwise-and operator?
|
||||
#pragma warning(disable : 6237) // warning C6237: (<zero> && <expression>) is always zero. <expression> is never evaluated and might have side effects
|
||||
#pragma warning(disable : 6235) // warning C6235: (<non-zero constant> || <expression>) is always a non-zero constant
|
||||
#pragma warning(disable : 6240) // warning C6240: (<expression> && <non-zero constant>) always evaluates to the result of <expression>. Did you intend to use the bitwise-and operator?
|
||||
|
||||
// These warnings aren't really important:
|
||||
#pragma warning(disable : 6323) // warning C6323: Use of arithmetic operator on Boolean type(s)
|
||||
|
||||
// Miscellaneous other /analyze warnings. We should consider fixing these at some point.
|
||||
//#pragma warning(disable : 6204) // warning C6204: Possible buffer overrun in call to 'memcpy': use of unchecked parameter 'src'
|
||||
//#pragma warning(disable : 6262) // warning C6262: Function uses '16464' bytes of stack: exceeds /analyze:stacksize'16384'. Consider moving some data to heap
|
||||
// This is a serious warning. Don't suppress it.
|
||||
//#pragma warning(disable : 6263) // warning C6263: Using _alloca in a loop: this can quickly overflow stack
|
||||
// 6328 is also used for passing __int64 to printf when int is expected so we can't suppress it.
|
||||
//#pragma warning(disable : 6328) // warning C6328: 'char' passed as parameter '1' when 'unsigned char' is required in call to 'V_isdigit'
|
||||
// /analyze doesn't like GCOMPILER_ASSERT's implementation of compile-time asserts
|
||||
#pragma warning(disable : 6326) // warning C6326: Potential comparison of a constant with another constant
|
||||
#pragma warning(disable : 6335) // warning C6335: Leaking process information handle 'pi.hThread'
|
||||
#pragma warning(disable : 6320) // warning C6320: Exception-filter expression is the constant EXCEPTION_EXECUTE_HANDLER. This might mask exceptions that were not intended to be handled
|
||||
#pragma warning(disable : 6250) // warning C6250: Calling 'VirtualFree' without the MEM_RELEASE flag might free memory but not address descriptors (VADs). This causes address space leaks
|
||||
#pragma warning(disable : 6384) // ientity2_class_h_schema_gen.cpp(76): warning C6384: Dividing sizeof a pointer by another value
|
||||
|
||||
// For temporarily suppressing warnings -- the warnings are suppressed for the next source line.
|
||||
#define ANALYZE_SUPPRESS(wnum) __pragma(warning(suppress: wnum))
|
||||
#define ANALYZE_SUPPRESS2(wnum1, wnum2) __pragma(warning(supress: wnum1 wnum2))
|
||||
#define ANALYZE_SUPPRESS3(wnum1, wnum2, wnum3) __pragma(warning(suppress: wnum1 wnum2 wnum3))
|
||||
#define ANALYZE_SUPPRESS4(wnum1, wnum2, wnum3, wnum4) __pragma(warning(suppress: wnum1 wnum2 wnum3 wnum4))
|
||||
|
||||
// Tag all printf style format strings with this
|
||||
#define PRINTF_FORMAT_STRING _Printf_format_string_
|
||||
#define SCANF_FORMAT_STRING _Scanf_format_string_impl_
|
||||
// Various macros for specifying the capacity of the buffer pointed
|
||||
// to by a function parameter. Variations include in/out/inout,
|
||||
// CAP (elements) versus BYTECAP (bytes), and null termination or
|
||||
// not (_Z).
|
||||
#define IN_Z _In_z_
|
||||
#define IN_CAP(x) _In_count_(x)
|
||||
#define IN_BYTECAP(x) _In_bytecount_(x)
|
||||
#define OUT_Z_CAP(x) _Out_z_cap_(x)
|
||||
#define OUT_CAP(x) _Out_cap_(x)
|
||||
#define OUT_BYTECAP(x) _Out_bytecap_(x)
|
||||
#define OUT_Z_BYTECAP(x) _Out_z_bytecap_(x)
|
||||
#define INOUT_BYTECAP(x) _Inout_bytecap_(x)
|
||||
#define INOUT_Z_CAP(x) _Inout_z_cap_(x)
|
||||
#define INOUT_Z_BYTECAP(x) _Inout_z_bytecap_(x)
|
||||
// These macros are use for annotating array reference parameters, typically used in functions
|
||||
// such as V_strcpy_safe. Because they are array references the capacity is already known.
|
||||
#if _MSC_VER >= 1700
|
||||
#define IN_Z_ARRAY _Pre_z_
|
||||
#define OUT_Z_ARRAY _Post_z_
|
||||
#define INOUT_Z_ARRAY _Prepost_z_
|
||||
#else
|
||||
#define IN_Z_ARRAY _Deref_pre_z_
|
||||
#define OUT_Z_ARRAY _Deref_post_z_
|
||||
#define INOUT_Z_ARRAY _Deref_prepost_z_
|
||||
#endif // _MSC_VER >= 1700
|
||||
// Use the macros above to annotate string functions that fill buffers as shown here,
|
||||
// in order to give VS's /analyze more opportunities to find bugs.
|
||||
// void V_wcsncpy( OUT_Z_BYTECAP(maxLenInBytes) wchar_t *pDest, wchar_t const *pSrc, int maxLenInBytes );
|
||||
// int V_snwprintf( OUT_Z_CAP(maxLenInCharacters) wchar_t *pDest, int maxLenInCharacters, PRINTF_FORMAT_STRING const wchar_t *pFormat, ... );
|
||||
|
||||
#endif // _PREFAST_
|
||||
#endif // _MSC_VER >= 1600 // VS 2010 and above.
|
||||
|
||||
#ifndef ANALYZE_SUPPRESS
|
||||
#define ANALYZE_SUPPRESS(wnum)
|
||||
#define ANALYZE_SUPPRESS2(wnum1, wnum2)
|
||||
#define ANALYZE_SUPPRESS3(wnum1, wnum2, wnum3)
|
||||
#define ANALYZE_SUPPRESS4(wnum1, wnum2, wnum3, wnum4)
|
||||
#define PRINTF_FORMAT_STRING
|
||||
#define SCANF_FORMAT_STRING
|
||||
#define IN_Z
|
||||
#define IN_CAP(x)
|
||||
#define IN_BYTECAP(x)
|
||||
#define OUT_Z_CAP(x)
|
||||
#define OUT_CAP(x)
|
||||
#define OUT_BYTECAP(x)
|
||||
#define OUT_Z_BYTECAP(x)
|
||||
#define INOUT_BYTECAP(x)
|
||||
#define INOUT_Z_CAP(x)
|
||||
#define INOUT_Z_BYTECAP(x)
|
||||
#define OUT_Z_ARRAY
|
||||
#define INOUT_Z_ARRAY
|
||||
#endif
|
||||
|
||||
#endif // ANALYSIS_ANNOTATIONS_H
|
@ -149,6 +149,27 @@
|
||||
|
||||
#endif // CROSS_PLATFORM_VERSION < 2
|
||||
|
||||
// VXConsole is enabled for...
|
||||
#if defined(_X360) || defined(_PS3)
|
||||
#define USE_VXCONSOLE 1
|
||||
#define HasVxConsole() 1
|
||||
#else
|
||||
#define HasVxConsole() 0
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Set up platform type defines.
|
||||
//-----------------------------------------------------------------------------
|
||||
#if defined( PLATFORM_X360 ) || defined( _PS3 )
|
||||
#ifndef _GAMECONSOLE
|
||||
#define _GAMECONSOLE
|
||||
#endif
|
||||
#define IsPC() 0
|
||||
#define IsGameConsole() 1
|
||||
#else
|
||||
#define IsPC() 1
|
||||
#define IsGameConsole() 0
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Set up build configuration defines.
|
||||
|
@ -49,6 +49,8 @@ enum class InterfaceStatus_t : int
|
||||
//-----------------------------------------------------------------------------
|
||||
typedef void* (*CreateInterfaceFn)(const char* pName, int* pReturnCode);
|
||||
typedef void* (*InstantiateInterfaceFn)();
|
||||
typedef HINSTANCE CSysModule;
|
||||
|
||||
struct InterfaceGlobals_t
|
||||
{
|
||||
InstantiateInterfaceFn m_pInterfacePtr;
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "vpc/keyvalues.h"
|
||||
#include "vpc/kvleaktrace.h"
|
||||
#include "vstdlib/keyvaluessystem.h"
|
||||
#include "filesystem/filesystem.h"
|
||||
#include "mathlib/color.h"
|
||||
#include "rtech/stryder/stryder.h"
|
||||
#include "engine/sys_dll2.h"
|
||||
|
@ -1,5 +1,4 @@
|
||||
#pragma once
|
||||
#include "filesystem/filesystem.h"
|
||||
#include "mathlib/color.h"
|
||||
|
||||
#define MAKE_3_BYTES_FROM_1_AND_2( x1, x2 ) (( (( uint16_t )x2) << 8 ) | (uint8_t)(x1))
|
||||
@ -12,6 +11,7 @@ extern vector<string> g_vGameInfoPaths;
|
||||
// Purpose: Forward declarations
|
||||
//---------------------------------------------------------------------------------
|
||||
class KeyValues;
|
||||
class CFileSystem_Stdio;
|
||||
|
||||
/* ==== KEYVALUES ======================================================================================================================================================= */
|
||||
inline CMemory p_KeyValues_Init;
|
||||
|
@ -251,6 +251,8 @@
|
||||
<ClInclude Include="..\public\iconcommand.h" />
|
||||
<ClInclude Include="..\public\iconvar.h" />
|
||||
<ClInclude Include="..\public\idebugoverlay.h" />
|
||||
<ClInclude Include="..\public\ifile.h" />
|
||||
<ClInclude Include="..\public\ifilesystem.h" />
|
||||
<ClInclude Include="..\public\ihandleentity.h" />
|
||||
<ClInclude Include="..\public\inetchannel.h" />
|
||||
<ClInclude Include="..\public\inetmsghandler.h" />
|
||||
@ -455,6 +457,7 @@
|
||||
<ClInclude Include="..\thirdparty\spdlog\include\stopwatch.h" />
|
||||
<ClInclude Include="..\thirdparty\spdlog\include\tweakme.h" />
|
||||
<ClInclude Include="..\thirdparty\spdlog\include\version.h" />
|
||||
<ClInclude Include="..\tier0\annotations.h" />
|
||||
<ClInclude Include="..\tier0\basetypes.h" />
|
||||
<ClInclude Include="..\tier0\commandline.h" />
|
||||
<ClInclude Include="..\tier0\commonmacros.h" />
|
||||
|
@ -1694,6 +1694,15 @@
|
||||
<ClInclude Include="..\tier1\utlrbtree.h">
|
||||
<Filter>sdk\tier1</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\public\ifilesystem.h">
|
||||
<Filter>sdk\public</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\public\ifile.h">
|
||||
<Filter>sdk\public</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\tier0\annotations.h">
|
||||
<Filter>sdk\tier0</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="..\shared\resource\lockedserver.png">
|
||||
|
@ -221,6 +221,8 @@
|
||||
<ClInclude Include="..\public\iconcommand.h" />
|
||||
<ClInclude Include="..\public\iconvar.h" />
|
||||
<ClInclude Include="..\public\icvar.h" />
|
||||
<ClInclude Include="..\public\ifile.h" />
|
||||
<ClInclude Include="..\public\ifilesystem.h" />
|
||||
<ClInclude Include="..\public\inetchannel.h" />
|
||||
<ClInclude Include="..\public\inetmsghandler.h" />
|
||||
<ClInclude Include="..\public\iserver.h" />
|
||||
@ -415,6 +417,7 @@
|
||||
<ClInclude Include="..\thirdparty\spdlog\include\stopwatch.h" />
|
||||
<ClInclude Include="..\thirdparty\spdlog\include\tweakme.h" />
|
||||
<ClInclude Include="..\thirdparty\spdlog\include\version.h" />
|
||||
<ClInclude Include="..\tier0\annotations.h" />
|
||||
<ClInclude Include="..\tier0\basetypes.h" />
|
||||
<ClInclude Include="..\tier0\commandline.h" />
|
||||
<ClInclude Include="..\tier0\commonmacros.h" />
|
||||
|
@ -1215,6 +1215,15 @@
|
||||
<ClInclude Include="..\tier1\utlrbtree.h">
|
||||
<Filter>sdk\tier1</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\public\ifilesystem.h">
|
||||
<Filter>sdk\public</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\public\ifile.h">
|
||||
<Filter>sdk\public</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\tier0\annotations.h">
|
||||
<Filter>sdk\tier0</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\common\opcodes.cpp">
|
||||
|
@ -276,6 +276,8 @@
|
||||
<ClInclude Include="..\public\iconvar.h" />
|
||||
<ClInclude Include="..\public\icvar.h" />
|
||||
<ClInclude Include="..\public\idebugoverlay.h" />
|
||||
<ClInclude Include="..\public\ifile.h" />
|
||||
<ClInclude Include="..\public\ifilesystem.h" />
|
||||
<ClInclude Include="..\public\ihandleentity.h" />
|
||||
<ClInclude Include="..\public\inetchannel.h" />
|
||||
<ClInclude Include="..\public\inetmsghandler.h" />
|
||||
@ -482,6 +484,7 @@
|
||||
<ClInclude Include="..\thirdparty\spdlog\include\stopwatch.h" />
|
||||
<ClInclude Include="..\thirdparty\spdlog\include\tweakme.h" />
|
||||
<ClInclude Include="..\thirdparty\spdlog\include\version.h" />
|
||||
<ClInclude Include="..\tier0\annotations.h" />
|
||||
<ClInclude Include="..\tier0\basetypes.h" />
|
||||
<ClInclude Include="..\tier0\commandline.h" />
|
||||
<ClInclude Include="..\tier0\commonmacros.h" />
|
||||
|
@ -1781,6 +1781,15 @@
|
||||
<ClInclude Include="..\tier1\utlfixedmemory.h">
|
||||
<Filter>sdk\tier1</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\public\ifilesystem.h">
|
||||
<Filter>sdk\public</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\public\ifile.h">
|
||||
<Filter>sdk\public</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\tier0\annotations.h">
|
||||
<Filter>sdk\tier0</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="..\shared\resource\lockedserver.png">
|
||||
|
@ -670,7 +670,7 @@ void VPK_Mount_f(const CCommand& args)
|
||||
return;
|
||||
}
|
||||
|
||||
VPKData_t* pPakData = FileSystem()->MountVPK(args.Arg(1));
|
||||
VPKData_t* pPakData = FileSystem()->MountVPKFile(args.Arg(1));
|
||||
if (pPakData)
|
||||
{
|
||||
DevMsg(eDLL_T::FS, "Mounted VPK file '%s' with handle '%i'\n", args.Arg(1), pPakData->m_nHandle);
|
||||
|
Loading…
x
Reference in New Issue
Block a user