added forgotten files
This commit is contained in:
@@ -327,8 +327,8 @@ void IConsole_Exec( int argc, char **argv)
|
|||||||
IFileHandle *f = filesystem->Open(argv[1], FILEMODE_READ);
|
IFileHandle *f = filesystem->Open(argv[1], FILEMODE_READ);
|
||||||
if (!f)
|
if (!f)
|
||||||
return;
|
return;
|
||||||
CUtlBuffer<char> b(f->Size()+1);
|
CUtlBuffer<char> b(filesystem->Size(f)+1);
|
||||||
f->Read(b, b.GetSize());
|
filesystem->Read(f, b, b.GetSize());
|
||||||
b[b.GetSize()-1] = 0;
|
b[b.GetSize()-1] = 0;
|
||||||
Console()->AddCommand(b);
|
Console()->AddCommand(b);
|
||||||
Console()->AddCommand(";");
|
Console()->AddCommand(";");
|
||||||
|
|||||||
@@ -11,10 +11,14 @@ extern "C" void FunnyMain( int argc, char **argv )
|
|||||||
{
|
{
|
||||||
CommandLine()->CreateCommandLine(argc, argv);
|
CommandLine()->CreateCommandLine(argc, argv);
|
||||||
|
|
||||||
|
void *pFilesystem = Plat_LoadLibrary("libfilesystem.so");
|
||||||
|
CreateInterfaceFn pFilesystemFactory = Sys_GetFactory(pFilesystem);
|
||||||
|
|
||||||
|
filesystem = (IFileSystem*)pFilesystemFactory(FILESYSTEM_INTERFACE_VERSION, NULL);
|
||||||
filesystem->Init();
|
filesystem->Init();
|
||||||
|
|
||||||
gamewindow->Init();
|
gamewindow->Init();
|
||||||
Materials()->Init();
|
g_pMaterialSystem->Init();
|
||||||
|
|
||||||
ServerGameDLL()->Init();
|
ServerGameDLL()->Init();
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
#define DLL_CLASS_EXPORT __attribute__ ((visibility("default")))
|
#define DLL_CLASS_EXPORT __attribute__ ((visibility("default")))
|
||||||
#define DLL_CLASS_IMPORT
|
#define DLL_CLASS_IMPORT
|
||||||
|
|
||||||
#define DLL_GLOBAL_EXPORT extern __attribute ((visibility("default")))
|
#define DLL_GLOBAL_EXPORT __attribute ((visibility("default")))
|
||||||
#define DLL_GLOBAL_IMPORT extern
|
#define DLL_GLOBAL_IMPORT extern
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -50,6 +50,11 @@
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__linux__)
|
||||||
|
#define POSIX
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define abstract_class class
|
#define abstract_class class
|
||||||
|
|
||||||
PLATFORM_INTERFACE void Plat_FatalErrorFunc( const char *szFormat, ... );
|
PLATFORM_INTERFACE void Plat_FatalErrorFunc( const char *szFormat, ... );
|
||||||
|
|||||||
@@ -26,11 +26,11 @@ public:
|
|||||||
static CInterfaceRegistry __Create##interfaceName##_registry( functionName, versionName );
|
static CInterfaceRegistry __Create##interfaceName##_registry( functionName, versionName );
|
||||||
|
|
||||||
#define EXPOSE_INTERFACE_GLOBALVAR( className, interfaceName, versionName, globalVarName ) \
|
#define EXPOSE_INTERFACE_GLOBALVAR( className, interfaceName, versionName, globalVarName ) \
|
||||||
static void *__Create##interfaceName##_interface() { return ( interfaceName* )( &globalVarName ); }; \
|
static void *__Create##className##_interface() { return ( interfaceName* )( &globalVarName ); }; \
|
||||||
static CInterfaceRegistry __Create##interfaceName##_registry( __Create##className##_interface, versionName );
|
static CInterfaceRegistry __Create##interfaceName##_registry( __Create##className##_interface, versionName );
|
||||||
|
|
||||||
|
|
||||||
void *CreateInterface( const char *szName, int *pReturnCode );
|
DLL_EXPORT void *CreateInterface( const char *szName, int *pReturnCode );
|
||||||
|
|
||||||
CreateInterfaceFn Sys_GetFactory( void *pLibrary );
|
CreateInterfaceFn Sys_GetFactory( void *pLibrary );
|
||||||
|
|
||||||
|
|||||||
@@ -25,15 +25,6 @@ class IFileHandle
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
IFileSystem *m_pFileSystem;
|
IFileSystem *m_pFileSystem;
|
||||||
|
|
||||||
size_t Write( const void *pData, size_t nDataSize );
|
|
||||||
size_t Read( void *pData, size_t nDataSize );
|
|
||||||
size_t Seek( ESeekMode eSeekMode, size_t nOffset );
|
|
||||||
size_t Tell( void );
|
|
||||||
size_t Size( void );
|
|
||||||
void Close( void );
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -68,19 +59,8 @@ public:
|
|||||||
void RegisterFileSystem();
|
void RegisterFileSystem();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define FILESYSTEM_INTERFACE_VERSION "FileSystem001"
|
||||||
|
|
||||||
extern IFileSystem *filesystem;
|
extern IFileSystem *filesystem;
|
||||||
extern IFileSystem *g_pFileSystems;
|
|
||||||
|
|
||||||
typedef IFileSystem *( *InstantiateFileSystemFn )( void );
|
|
||||||
class CFileSystemRegistry
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CFileSystemRegistry( InstantiateFileSystemFn fn, const char *szFileSystem );
|
|
||||||
};
|
|
||||||
|
|
||||||
#define EXPOSE_FILESYSTEM( className, filesystemName ) \
|
|
||||||
static IFileSystem *__Create##className##_filesystem() { return ( IFileSystem* )( new className ); }; \
|
|
||||||
static CFileSystemRegistry __Create##className##_registry( __Create##className##_filesystem, filesystemName );
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
0
stdfilesystems/build.cpp
Normal file
0
stdfilesystems/build.cpp
Normal file
@@ -47,9 +47,9 @@ public:
|
|||||||
pHandle = new CLIBCFileHandle;
|
pHandle = new CLIBCFileHandle;
|
||||||
pHandle->m_pFileSystem = this;
|
pHandle->m_pFileSystem = this;
|
||||||
pHandle->m_pFile = pFile;
|
pHandle->m_pFile = pFile;
|
||||||
pHandle->Seek(SEEKMODE_RELATIVE_END, 0);
|
Seek(pHandle,SEEKMODE_RELATIVE_END, 0);
|
||||||
pHandle->m_nSize = pHandle->Tell();
|
pHandle->m_nSize = Tell(pHandle);
|
||||||
pHandle->Seek(SEEKMODE_RELATIVE_START, 0);
|
Seek(pHandle, SEEKMODE_RELATIVE_START, 0);
|
||||||
return pHandle;
|
return pHandle;
|
||||||
}
|
}
|
||||||
virtual size_t Write( IFileHandle *pFile, const void *pData, size_t nDataSize ) override
|
virtual size_t Write( IFileHandle *pFile, const void *pData, size_t nDataSize ) override
|
||||||
@@ -121,4 +121,4 @@ public:
|
|||||||
virtual const char *ReadString( IFileHandle *pFile ) override { return NULL; };
|
virtual const char *ReadString( IFileHandle *pFile ) override { return NULL; };
|
||||||
};
|
};
|
||||||
|
|
||||||
EXPOSE_FILESYSTEM(CLIBCFileSystem, "sysfs");
|
EXPOSE_INTERFACE(CLIBCFileSystem, IFileSystem, FILESYSTEM_INTERFACE_VERSION)
|
||||||
32
tier0/build.cpp
Normal file
32
tier0/build.cpp
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
#include "helper.h"
|
||||||
|
#include "c.h"
|
||||||
|
#include "ld.h"
|
||||||
|
#include "tier1/utlstring.h"
|
||||||
|
#include "tier1/commandline.h"
|
||||||
|
|
||||||
|
CUtlVector<CUtlString> tier0_CompiledFiles = {
|
||||||
|
"lib.cpp",
|
||||||
|
"mem.cpp",
|
||||||
|
"platform.cpp",
|
||||||
|
"network.cpp",
|
||||||
|
};
|
||||||
|
|
||||||
|
DECLARE_BUILD_STAGE(tier0)
|
||||||
|
{
|
||||||
|
CProject_t compileProject = {};
|
||||||
|
LinkProject_t ldProject = {};
|
||||||
|
CUtlString szOutputProject = "";
|
||||||
|
|
||||||
|
compileProject.m_szName = "tier0";
|
||||||
|
compileProject.files = tier0_CompiledFiles;
|
||||||
|
compileProject.includeDirectories = {"../public"};
|
||||||
|
compileProject.bFPIC = true;
|
||||||
|
ldProject = ccompiler->Compile(&compileProject);
|
||||||
|
|
||||||
|
ldProject.linkType = ELINK_DYNAMIC_LIBRARY;
|
||||||
|
szOutputProject = linker->Link(&ldProject);
|
||||||
|
|
||||||
|
ADD_OUTPUT_LIBRARY(szOutputProject);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
@@ -1,7 +1,4 @@
|
|||||||
#include "tier0/network.h"
|
#include "tier0/network.h"
|
||||||
#include "steam/isteamnetworkingsockets.h"
|
|
||||||
#include "steam/isteamnetworkingutils.h"
|
|
||||||
#include "steam/steamnetworkingtypes.h"
|
|
||||||
#include "tier1/commandline.h"
|
#include "tier1/commandline.h"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -214,18 +214,20 @@ PLATFORM_INTERFACE const char *Plat_GetEnv( const char *szVar )
|
|||||||
|
|
||||||
PLATFORM_INTERFACE void Plat_SetWorkingDir( const char *psz )
|
PLATFORM_INTERFACE void Plat_SetWorkingDir( const char *psz )
|
||||||
{
|
{
|
||||||
|
chdir(psz);
|
||||||
}
|
}
|
||||||
|
|
||||||
PLATFORM_INTERFACE const char *Plat_GetWorkingDir( void )
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef MAX_PATH
|
#ifndef MAX_PATH
|
||||||
#define MAX_PATH 4096
|
#define MAX_PATH 4096
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
PLATFORM_INTERFACE const char *Plat_GetWorkingDir( void )
|
||||||
|
{
|
||||||
|
static char szCwd[MAX_PATH];
|
||||||
|
getcwd(szCwd, MAX_PATH);
|
||||||
|
return szCwd;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static char s_szExecutablePath[MAX_PATH];
|
static char s_szExecutablePath[MAX_PATH];
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
static ssize_t s_iExecutablePathSize = readlink("/proc/self/exe", s_szExecutablePath, MAX_PATH);
|
static ssize_t s_iExecutablePathSize = readlink("/proc/self/exe", s_szExecutablePath, MAX_PATH);
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ CUtlVector<CUtlString> tier1_CompiledFiles = {
|
|||||||
"tier1/utlstring.cpp",
|
"tier1/utlstring.cpp",
|
||||||
"tier1/utlvector.cpp",
|
"tier1/utlvector.cpp",
|
||||||
};
|
};
|
||||||
CUtlString tier1_lib;
|
|
||||||
|
|
||||||
DECLARE_BUILD_STAGE(tier1)
|
DECLARE_BUILD_STAGE(tier1)
|
||||||
{
|
{
|
||||||
@@ -22,13 +21,15 @@ DECLARE_BUILD_STAGE(tier1)
|
|||||||
|
|
||||||
compileProject.m_szName = "tier1";
|
compileProject.m_szName = "tier1";
|
||||||
compileProject.files = tier1_CompiledFiles;
|
compileProject.files = tier1_CompiledFiles;
|
||||||
compileProject.includeDirectories = all_IncludeDirectories;
|
compileProject.includeDirectories = {"../public"};
|
||||||
compileProject.bFPIC = true;
|
compileProject.bFPIC = true;
|
||||||
ldProject = ccompiler->Compile(&compileProject);
|
ldProject = ccompiler->Compile(&compileProject);
|
||||||
ldProject.linkType = ELINK_STATIC_LIBRARY;
|
ldProject.linkType = ELINK_STATIC_LIBRARY;
|
||||||
|
|
||||||
CUtlString outputProject = linker->Link(&ldProject);
|
CUtlString szOutputDir = linker->Link(&ldProject);
|
||||||
tier1_lib = outputProject;
|
|
||||||
|
ADD_OUTPUT_LIBRARY(szOutputDir)
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|||||||
34
tier1/build.cpp
Normal file
34
tier1/build.cpp
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
#include "helper.h"
|
||||||
|
#include "c.h"
|
||||||
|
#include "ld.h"
|
||||||
|
#include "tier1/utlstring.h"
|
||||||
|
#include "tier1/commandline.h"
|
||||||
|
|
||||||
|
CUtlVector<CUtlString> tier1_CompiledFiles = {
|
||||||
|
"interface.cpp",
|
||||||
|
"appinit.cpp",
|
||||||
|
"commandline.cpp",
|
||||||
|
"utlbuffer.cpp",
|
||||||
|
"utlmap.cpp",
|
||||||
|
"utlstring.cpp",
|
||||||
|
"utlvector.cpp",
|
||||||
|
};
|
||||||
|
|
||||||
|
DECLARE_BUILD_STAGE(tier1)
|
||||||
|
{
|
||||||
|
CProject_t compileProject = {};
|
||||||
|
LinkProject_t ldProject = {};
|
||||||
|
|
||||||
|
compileProject.m_szName = "tier1";
|
||||||
|
compileProject.files = tier1_CompiledFiles;
|
||||||
|
compileProject.includeDirectories = {"../public"};
|
||||||
|
compileProject.bFPIC = true;
|
||||||
|
ldProject = ccompiler->Compile(&compileProject);
|
||||||
|
ldProject.linkType = ELINK_STATIC_LIBRARY;
|
||||||
|
|
||||||
|
CUtlString szOutputDir = linker->Link(&ldProject);
|
||||||
|
|
||||||
|
ADD_OUTPUT_LIBRARY(szOutputDir)
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
BIN
tier1/commandline.o
Normal file
BIN
tier1/commandline.o
Normal file
Binary file not shown.
@@ -1,18 +1,23 @@
|
|||||||
#include "tier1/interface.h"
|
#include "tier1/interface.h"
|
||||||
#include "tier1/utlvector.h"
|
#include "tier1/utlvector.h"
|
||||||
|
#include "dlfcn.h"
|
||||||
|
|
||||||
|
static CInterfaceRegistry *s_pInterfaceRegistries;
|
||||||
|
|
||||||
CInterfaceRegistry *g_pInterfaceRegistries = NULL;
|
|
||||||
CInterfaceRegistry::CInterfaceRegistry( InstantiateInterfaceFn fn, const char *szName )
|
CInterfaceRegistry::CInterfaceRegistry( InstantiateInterfaceFn fn, const char *szName )
|
||||||
: m_szName(szName)
|
: m_szName(szName)
|
||||||
{
|
{
|
||||||
m_CreateFn = fn;
|
m_CreateFn = fn;
|
||||||
m_pNext = g_pInterfaceRegistries;
|
m_pNext = s_pInterfaceRegistries;
|
||||||
g_pInterfaceRegistries = this;
|
s_pInterfaceRegistries = this;
|
||||||
|
Dl_info info = {};
|
||||||
|
dladdr((void *)&s_pInterfaceRegistries, &info);
|
||||||
|
printf("%p: %s in %s\n",&s_pInterfaceRegistries, m_szName, info.dli_fname);
|
||||||
};
|
};
|
||||||
|
|
||||||
void *CreateInterface( const char *szName, int *pReturnCode )
|
DLL_EXPORT void *CreateInterface( const char *szName, int *pReturnCode )
|
||||||
{
|
{
|
||||||
CInterfaceRegistry *pRegistry = g_pInterfaceRegistries;
|
CInterfaceRegistry *pRegistry = s_pInterfaceRegistries;
|
||||||
while (pRegistry)
|
while (pRegistry)
|
||||||
{
|
{
|
||||||
if (!V_strcmp(szName, pRegistry->m_szName))
|
if (!V_strcmp(szName, pRegistry->m_szName))
|
||||||
@@ -30,5 +35,8 @@ void *CreateInterface( const char *szName, int *pReturnCode )
|
|||||||
|
|
||||||
CreateInterfaceFn Sys_GetFactory( void *lib )
|
CreateInterfaceFn Sys_GetFactory( void *lib )
|
||||||
{
|
{
|
||||||
|
#ifdef POSIX
|
||||||
|
return CreateInterface;
|
||||||
|
#endif
|
||||||
return (CreateInterfaceFn)Plat_GetProc(lib, "CreateInterface");
|
return (CreateInterfaceFn)Plat_GetProc(lib, "CreateInterface");
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
tier1/interface.o
Normal file
BIN
tier1/interface.o
Normal file
Binary file not shown.
BIN
tier1/utlbuffer.o
Normal file
BIN
tier1/utlbuffer.o
Normal file
Binary file not shown.
BIN
tier1/utlmap.o
Normal file
BIN
tier1/utlmap.o
Normal file
Binary file not shown.
BIN
tier1/utlstring.o
Normal file
BIN
tier1/utlstring.o
Normal file
Binary file not shown.
BIN
tier1/utlvector.o
Normal file
BIN
tier1/utlvector.o
Normal file
Binary file not shown.
@@ -5,10 +5,10 @@
|
|||||||
#include "tier1/commandline.h"
|
#include "tier1/commandline.h"
|
||||||
|
|
||||||
CUtlVector<CUtlString> tier2_CompiledFiles = {
|
CUtlVector<CUtlString> tier2_CompiledFiles = {
|
||||||
"tier2/fileformats/ini.cpp",
|
"fileformats/ini.cpp",
|
||||||
"tier2/fileformats/json.cpp",
|
"fileformats/json.cpp",
|
||||||
"tier2/filesystem.cpp",
|
"filesystem.cpp",
|
||||||
"tier2/filesystem_libc.cpp",
|
"filesystem_libc.cpp",
|
||||||
};
|
};
|
||||||
CUtlString tier2_lib;
|
CUtlString tier2_lib;
|
||||||
|
|
||||||
|
|||||||
32
tier2/build.cpp
Normal file
32
tier2/build.cpp
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
#include "helper.h"
|
||||||
|
#include "c.h"
|
||||||
|
#include "ld.h"
|
||||||
|
#include "tier1/utlstring.h"
|
||||||
|
#include "tier1/commandline.h"
|
||||||
|
|
||||||
|
CUtlVector<CUtlString> tier2_CompiledFiles = {
|
||||||
|
"fileformats/ini.cpp",
|
||||||
|
"fileformats/json.cpp",
|
||||||
|
"filesystem.cpp",
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
DECLARE_BUILD_STAGE(tier2)
|
||||||
|
{
|
||||||
|
V_printf("%s\n", Plat_GetWorkingDir());
|
||||||
|
CProject_t compileProject = {};
|
||||||
|
LinkProject_t ldProject = {};
|
||||||
|
|
||||||
|
compileProject.m_szName = "tier2";
|
||||||
|
compileProject.files = tier2_CompiledFiles;
|
||||||
|
compileProject.includeDirectories = {"../public"};
|
||||||
|
compileProject.bFPIC = true;
|
||||||
|
ldProject = ccompiler->Compile(&compileProject);
|
||||||
|
ldProject.linkType = ELINK_STATIC_LIBRARY;
|
||||||
|
|
||||||
|
CUtlString szOutputProject = linker->Link(&ldProject);
|
||||||
|
|
||||||
|
ADD_OUTPUT_LIBRARY(szOutputProject)
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
@@ -92,16 +92,15 @@ public:
|
|||||||
IINIFile *CINIManager::ReadFile( const char *psz )
|
IINIFile *CINIManager::ReadFile( const char *psz )
|
||||||
{
|
{
|
||||||
IFileHandle *pFile;
|
IFileHandle *pFile;
|
||||||
CUtlBuffer<char> data;
|
const char *szData;
|
||||||
|
|
||||||
pFile = filesystem->Open(psz, FILEMODE_READ);
|
pFile = filesystem->Open(psz, FILEMODE_READ);
|
||||||
if (!pFile)
|
if (!pFile)
|
||||||
return NULL;
|
return NULL;
|
||||||
data = CUtlBuffer<char>(pFile->Size()+1);
|
szData = filesystem->ReadString(pFile);
|
||||||
uint32_t nSize = pFile->Read(data.GetMemory(), pFile->Size());
|
filesystem->Close(pFile);
|
||||||
pFile->Close();
|
|
||||||
|
|
||||||
return ReadString(data.GetMemory());
|
return ReadString(szData);
|
||||||
}
|
}
|
||||||
|
|
||||||
IINIFile *CINIManager::ReadString( const char *psz )
|
IINIFile *CINIManager::ReadString( const char *psz )
|
||||||
|
|||||||
BIN
tier2/fileformats/ini.o
Normal file
BIN
tier2/fileformats/ini.o
Normal file
Binary file not shown.
@@ -1,121 +1,4 @@
|
|||||||
#include "tier1/utlbuffer.h"
|
|
||||||
#include "tier2/ifilesystem.h"
|
#include "tier2/ifilesystem.h"
|
||||||
#include "tier1/interface.h"
|
|
||||||
#include "tier0/lib.h"
|
|
||||||
#include <cstdio>
|
|
||||||
|
|
||||||
size_t IFileHandle::Write( const void *pData, size_t nDataSize )
|
IFileSystem *filesystem;
|
||||||
{
|
|
||||||
return m_pFileSystem->Write(this, pData, nDataSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t IFileHandle::Read( void *pData, size_t nDataSize )
|
|
||||||
{
|
|
||||||
return m_pFileSystem->Read(this, pData, nDataSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t IFileHandle::Seek( ESeekMode eSeekMode, size_t nOffset )
|
|
||||||
{
|
|
||||||
return m_pFileSystem->Seek(this, eSeekMode, nOffset);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t IFileHandle::Tell( void )
|
|
||||||
{
|
|
||||||
return m_pFileSystem->Tell(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t IFileHandle::Size( void )
|
|
||||||
{
|
|
||||||
return m_pFileSystem->Size(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void IFileHandle::Close( void )
|
|
||||||
{
|
|
||||||
m_pFileSystem->Close(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class CFileSystem : public IFileSystem
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual void Init() override {
|
|
||||||
};
|
|
||||||
virtual void Shutdown() override {
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
virtual IFileHandle *Open( const char *szFileName, int eOpCode ) override
|
|
||||||
{
|
|
||||||
IFileSystem *pFileSystem;
|
|
||||||
IFileHandle *pHandle = NULL;
|
|
||||||
|
|
||||||
for ( pFileSystem = g_pFileSystems; pFileSystem; pFileSystem = pFileSystem->m_pNext )
|
|
||||||
{
|
|
||||||
pHandle = pFileSystem->Open(szFileName, eOpCode);
|
|
||||||
if (pHandle) return pHandle;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual size_t Write( IFileHandle *pFile, const void *pData, size_t nDataSize ) override
|
|
||||||
{
|
|
||||||
return pFile->Write(pData, nDataSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual size_t Read( IFileHandle *pFile, void *pData, size_t nDataSize ) override
|
|
||||||
{
|
|
||||||
return pFile->Read(pData, nDataSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual size_t Seek( IFileHandle *pFile, ESeekMode eSeekMode, size_t nOffset ) override
|
|
||||||
{
|
|
||||||
return pFile->Seek(eSeekMode, nOffset);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual size_t Tell( IFileHandle *pFile ) override
|
|
||||||
{
|
|
||||||
return pFile->Tell();
|
|
||||||
}
|
|
||||||
virtual size_t Size( IFileHandle *pFile ) override
|
|
||||||
{
|
|
||||||
return pFile->Size();
|
|
||||||
}
|
|
||||||
virtual void Close( IFileHandle *pFile ) override
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
virtual CUtlBuffer<unsigned char> Read( IFileHandle *pFile ) override
|
|
||||||
{
|
|
||||||
CUtlBuffer<unsigned char> buffer;
|
|
||||||
buffer = CUtlBuffer<unsigned char>(Size(pFile));
|
|
||||||
|
|
||||||
Read(pFile, buffer.GetMemory(), buffer.GetSize());
|
|
||||||
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
virtual const char *ReadString( IFileHandle *pFile ) override {
|
|
||||||
char *szString = (char*)V_malloc(Size(pFile)+1);
|
|
||||||
Read(pFile, szString, Size(pFile));
|
|
||||||
szString[Size(pFile)] = 0;
|
|
||||||
return szString;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static CFileSystem s_fileSystem;
|
|
||||||
IFileSystem *filesystem = &s_fileSystem;
|
|
||||||
|
|
||||||
IFileSystem *g_pFileSystems;
|
|
||||||
|
|
||||||
CFileSystemRegistry::CFileSystemRegistry( InstantiateFileSystemFn fn, const char *szFileSystem )
|
|
||||||
{
|
|
||||||
IFileSystem *pFileSystem = fn();
|
|
||||||
pFileSystem->RegisterFileSystem();
|
|
||||||
}
|
|
||||||
|
|
||||||
void IFileSystem::RegisterFileSystem()
|
|
||||||
{
|
|
||||||
m_pNext = g_pFileSystems;
|
|
||||||
g_pFileSystems = this;
|
|
||||||
};
|
|
||||||
|
|||||||
BIN
tier2/filesystem.o
Normal file
BIN
tier2/filesystem.o
Normal file
Binary file not shown.
Reference in New Issue
Block a user