This commit is contained in:
nephacks
2025-06-04 03:22:50 +02:00
parent f234f23848
commit f12416cffd
14243 changed files with 6446499 additions and 26 deletions

363
utils/dx_proxy/dx_proxy.cpp Normal file
View File

@@ -0,0 +1,363 @@
//========= Copyright <20> 1996-2006, Valve Corporation, All rights reserved. ============//
//
// Purpose: Proxy for D3DX routines
//
// $NoKeywords: $
//
//=============================================================================//
//
#include <windows.h>
#include <vector>
// Aux function prototype
const char * WINAPI GetDllVersion( void );
#ifdef _DEBUG
#define D3D_DEBUG_INFO 1
#endif
//
// DX9_V00_PC
//
// D3DX static library
// MSFT file version: 5.3.0000001.0904
//
#ifdef DX9_V00_PC
#ifdef DX_PROXY_INC_CONFIG
# error "DX9_V00_PC: Multiple DX_PROXY configurations disallowed!"
#endif
#define DX_PROXY_INC_CONFIG
#pragma message ( "Compiling DX_PROXY for DX9_V00_PC" )
#pragma comment ( lib, "../../dx9sdk/lib/d3dx9" )
#include "../../dx9sdk/include/d3dx9shader.h"
#endif // #ifdef DX9_V00_PC
//
// DX9_X360
//
// D3DX win32 static library
// MSFT X360 SDK
//
#ifdef DX9_V00_X360
#ifdef DX_PROXY_INC_CONFIG
# error "DX9_V00_X360: Multiple DX_PROXY configurations disallowed!"
#endif
#define DX_PROXY_INC_CONFIG
#pragma message ( "Compiling DX_PROXY for DX9_V00_X360" )
// Avoid including XBOX math stuff
#define _NO_XBOXMATH
#define __D3DX9MATH_INL__
#include "d3dx9shader.h"
#endif // #ifdef DX9_V00_X360
//
// DX9_V30_PC
//
// 1. D3DX static import library
// 2. resource dynamic library d3dx9_33.dll
//
// MSFT file version: 9.16.843.0000
// Distribution: Dec 2006 DirectX SDK
//
// Implementation note: need to delayload d3dx9_33
// because the module should be extracted from resources first.
// Make sure "/DELAYLOAD:d3dx9_33.dll" is passed to linker.
//
#ifdef DX9_V30_PC
#ifdef DX_PROXY_INC_CONFIG
# error "DX9_V30_PC: Multiple DX_PROXY configurations disallowed!"
#endif
#define DX_PROXY_INC_CONFIG
#pragma message ( "Compiling DX_PROXY for DX9_V30_PC" )
#pragma comment( lib, "delayimp" )
#pragma comment ( lib, "../../dx10sdk/lib/x86/d3dx9" )
#include "../../dx10sdk/include/d3dx9shader.h"
#endif // #ifdef DX9_V30_PC
//
// DX10_V00_PC
//
// 1. D3DX static import library
// 2. resource dynamic library d3dx10.dll
//
// MSFT file version: 9.16.843.0000
// Distribution: Dec 2006 DirectX SDK
//
// Implementation note: need to delayload d3dx10
// because the module should be extracted from resources first.
// Make sure "/DELAYLOAD:d3dx10.dll" is passed to linker.
//
#ifdef DX10_V00_PC
#ifdef DX_PROXY_INC_CONFIG
# error "DX10_V00_PC: Multiple DX_PROXY configurations disallowed!"
#endif
#define DX_PROXY_INC_CONFIG
#pragma message ( "Compiling DX_PROXY for DX10_V00_PC" )
#pragma comment( lib, "delayimp" )
#pragma comment ( lib, "../../dx10sdk/lib/x86/d3dx10" )
#include "../../dx10sdk/include/d3dx10.h"
typedef D3D10_SHADER_MACRO D3DXMACRO;
typedef LPD3D10INCLUDE LPD3DXINCLUDE;
typedef ID3D10Include ID3DXInclude;
typedef D3D10_INCLUDE_TYPE D3DXINCLUDE_TYPE;
typedef ID3D10Blob* LPD3DXBUFFER;
typedef void* LPD3DXCONSTANTTABLE;
#endif // #ifdef DX10_V00_PC
//
// No DX configuration
#ifndef DX_PROXY_INC_CONFIG
# error "DX9_PC or DX9_X360 must be defined!"
#endif // #ifndef DX_PROXY_INC_CONFIG
//
// ExtractDependencies
//
// Retrieves all the additional required binaries from the resources and
// places them to a temporary location. Then the binaries are mapped into
// the address space of the calling process.
//
static BOOL ExtractDependencies( void )
{
return TRUE;
/*
BOOL bResult = TRUE;
char chSyncName[0x30];
char const *szDllVersion = GetDllVersion();
sprintf( chSyncName, "%s_MTX", szDllVersion );
HANDLE hMutex = ::CreateMutex( NULL, FALSE, chSyncName );
if ( !hMutex )
return FALSE;
DWORD dwWaitResult = ::WaitForSingleObject( hMutex, INFINITE );
if ( dwWaitResult != WAIT_OBJECT_0 )
return FALSE;
// Now we own the mutex
char chExtractPath[0x100] = { 0 };
if ( char const *pszTemp = getenv( "TEMP" ) )
sprintf( chExtractPath, "%s\\", pszTemp );
else if ( char const *pszTmp = getenv( "TMP" ) )
sprintf( chExtractPath, "%s\\", pszTmp );
else
bResult = FALSE;
if ( bResult )
{
sprintf( chExtractPath + strlen( chExtractPath ), "%s", szDllVersion );
bResult = ::CreateDirectory( chExtractPath, NULL );
if ( bResult )
{
sprintf( chExtractPath + strlen( chExtractPath ), "\\" );
char const * const arrNames[] = {
#ifdef DX9_V33_PC
"d3dx9_33.dll", MAKEINTRESOURCE( 1 ),
#else
#endif
NULL
};
// Now loop over the names
for ( int k = 0; k < sizeof( arrNames ) / ( 2 * sizeof( arrNames[0] ) ); ++ k )
{
char const * const &szName = arrNames[ 2 * k ];
char const * const &szResource = 1[ &szName ];
char chCreateFileName[0x200];
sprintf( chCreateFileName, "%s%s", chExtractPath, szName );
HANDLE hFile = CreateFile( chCreateFileName, FILE_ALL_ACCESS, FILE_SHARE_READ, NULL, CREATE_NEW,
FILE_ATTRIBUTE_HIDDEN | FILE_FLAG_DELETE_ON_CLOSE, NULL );
#error "This is how you can create temp needed resources"
}
}
}
::ReleaseMutex( hMutex );
::CloseHandle( hMutex );
return bResult;
*/
}
// DLL entry point: DllMain
BOOL WINAPI DllMain(
HINSTANCE hinstDLL,
DWORD fdwReason,
LPVOID lpvReserved
)
{
/*UNUSED_ALWAYS*/( hinstDLL );
/*UNUSED_ALWAYS*/( lpvReserved );
switch ( fdwReason )
{
case DLL_PROCESS_ATTACH:
// Process is attaching - make sure it can find the dependencies
return ExtractDependencies();
}
return TRUE;
}
// Obtain DLL version
#pragma comment(linker, "/EXPORT:GetDllVersionLong=?GetDllVersionLong@@YGPBDXZ")
const char * WINAPI GetDllVersionLong( void )
{
#if defined( DX9_V00_PC ) && defined( _DEBUG )
return "{DX_PROXY for DX9_V00_PC DEBUG}";
#endif
#if defined( DX9_V00_PC ) && defined( NDEBUG )
return "{DX_PROXY for DX9_V00_PC RELEASE}";
#endif
#if defined( DX9_V00_X360 ) && defined( _DEBUG )
return "{DX_PROXY for DX9_V00_X360 DEBUG}";
#endif
#if defined( DX9_V00_X360 ) && defined( NDEBUG )
return "{DX_PROXY for DX9_V00_X360 RELEASE}";
#endif
#if defined( DX9_V30_PC ) && defined( _DEBUG )
return "{DX_PROXY for DX9_V30_PC DEBUG}";
#endif
#if defined( DX9_V30_PC ) && defined( NDEBUG )
return "{DX_PROXY for DX9_V30_PC RELEASE}";
#endif
#if defined( DX10_V00_PC ) && defined( _DEBUG )
return "{DX_PROXY for DX10_V00_PC DEBUG}";
#endif
#if defined( DX10_V00_PC ) && defined( NDEBUG )
return "{DX_PROXY for DX10_V00_PC RELEASE}";
#endif
}
#pragma comment(linker, "/EXPORT:GetDllVersion=?GetDllVersion@@YGPBDXZ")
const char * WINAPI GetDllVersion( void )
{
#if defined( DX9_V00_PC ) && defined( _DEBUG )
return "DXPRX_DX9_V00_PC_d";
#endif
#if defined( DX9_V00_PC ) && defined( NDEBUG )
return "DXPRX_DX9_V00_PC_r";
#endif
#if defined( DX9_V00_X360 ) && defined( _DEBUG )
return "DXPRX_DX9_V00_X360_d";
#endif
#if defined( DX9_V00_X360 ) && defined( NDEBUG )
return "DXPRX_DX9_V00_X360_r";
#endif
#if defined( DX9_V30_PC ) && defined( _DEBUG )
return "DXPRX_DX9_V30_PC_d";
#endif
#if defined( DX9_V30_PC ) && defined( NDEBUG )
return "DXPRX_DX9_V30_PC_r";
#endif
#if defined( DX10_V00_PC ) && defined( _DEBUG )
return "DXPRX_DX10_V00_PC_d";
#endif
#if defined( DX10_V00_PC ) && defined( NDEBUG )
return "DXPRX_DX10_V00_PC_r";
#endif
}
#include "filememcache.h"
#include "dxincludeimpl.h"
char s_dummyBuffer[ 512 ];
// Proxied routines
//__declspec(dllexport) - undef this to figure out the new decorated name in case you update the direct3d headers
HRESULT WINAPI
Proxy_D3DXCompileShaderFromFile(
LPCSTR pSrcFile,
CONST D3DXMACRO* pDefines,
LPD3DXINCLUDE pInclude,
LPCSTR pFunctionName,
LPCSTR pProfile,
DWORD Flags,
LPD3DXBUFFER* ppShader,
LPD3DXBUFFER* ppErrorMsgs,
LPD3DXCONSTANTTABLE* ppConstantTable )
{
if ( !pInclude )
pInclude = &s_incDxImpl;
// Open the top-level file via our include interface
LPCVOID lpcvData;
UINT numBytes;
HRESULT hr = pInclude->Open( ( D3DXINCLUDE_TYPE ) 0, pSrcFile, NULL, &lpcvData, &numBytes
#if defined( DX9_V00_X360 )
, s_dummyBuffer, sizeof( s_dummyBuffer )
#endif
);
if ( FAILED( hr ) )
return hr;
LPCSTR pShaderData = ( LPCSTR ) lpcvData;
#if defined( DX9_V00_PC ) || defined( DX9_V30_PC ) || defined( DX9_V00_X360 )
#pragma comment(linker, "/EXPORT:Proxy_D3DXCompileShaderFromFile=?Proxy_D3DXCompileShaderFromFile@@YGJPBDPBU_D3DXMACRO@@PAUID3DXInclude@@00KPAPAUID3DXBuffer@@3PAPAUID3DXConstantTable@@@Z")
hr = D3DXCompileShader( pShaderData, numBytes, pDefines, pInclude, pFunctionName, pProfile, Flags, ppShader, ppErrorMsgs, ppConstantTable );
#endif
#if defined( DX10_V00_PC )
#pragma comment(linker, "/EXPORT:Proxy_D3DXCompileShaderFromFile=?Proxy_D3DXCompileShaderFromFile@@YGJPBDPBU_D3D_SHADER_MACRO@@PAUID3DInclude@@00KPAPAUID3D10Blob@@3PAPAX@Z")
hr = D3DX10CompileFromMemory( pShaderData, numBytes, pSrcFile, pDefines, pInclude, pFunctionName, pProfile, Flags, 0, NULL, ppShader, ppErrorMsgs, NULL );
#endif
// Close the file
pInclude->Close( lpcvData );
return hr;
}

View File

@@ -0,0 +1,38 @@
$Project "dx_proxy_dx9_v00_pc"
{
"utils\dx_proxy\dx_proxy_dx9_v00_pc.vpc" [$WINDOWS]
}
$Project "dx_proxy_dx9_v30_pc"
{
"utils\dx_proxy\dx_proxy_dx9_v30_pc.vpc" [$WINDOWS]
}
$Project "dx_proxy_dx9_v00_x360"
{
"utils\dx_proxy\dx_proxy_dx9_v00_x360.vpc" [$WINDOWS]
}
$Project "dx_proxy_dx10_v00_pc"
{
"utils\dx_proxy\dx_proxy_dx10_v00_pc.vpc" [$WINDOWS]
}
$Project "dx_proxy_ps3"
{
"utils\dx_proxy\dx_proxy_ps3.vpc" [$WINDOWS]
}
$Group "dx_proxy" "source" "everything"
{
"dx_proxy_dx10_v00_pc"
"dx_proxy_dx9_v00_pc"
"dx_proxy_dx9_v30_pc"
//"dx_proxy_dx9_v00_x360"
"dx_proxy_ps3"
}

View File

@@ -0,0 +1,76 @@
//
// dx_proxy_base.vpc
//
// Base script for generating dx_proxy.dll for different
// versions of Microsoft DirectX SDK
//
$MacroRequired "SRCDIR"
$MacroRequired "OUTBINDIR"
$MacroRequired "DX_SDK_VER"
$Macro OUTBINNAME "dx_proxy"
$Include "$SRCDIR\vpc_scripts\source_dll_base.vpc"
$Configuration "Debug"
{
$General
{
$OutputDirectory ".\Debug_$DX_SDK_VER"
$IntermediateDirectory ".\Debug_$DX_SDK_VER"
}
}
$Configuration "Release"
{
$General
{
$OutputDirectory ".\Release_$DX_SDK_VER"
$IntermediateDirectory ".\Release_$DX_SDK_VER"
}
}
$Configuration
{
$General
{
$TargetName "dx_proxy"
}
$Compiler
{
$PreprocessorDefinitions "$BASE;DX_PROXY_EXPORTS;$DX_SDK_VER"
$EnableC++Exceptions "Yes (/EHsc)"
}
$Linker
{
$IgnoreSpecificLibrary "libcp.lib; libcpd.lib"
}
}
$Project
{
$Folder "Source Files"
{
-$File "$SRCDIR\public\tier0\memoverride.cpp"
$File "dx_proxy.cpp"
$File "filememcache.cpp"
}
$Folder "Header Files"
{
$File "$SRCDIR\common\dx_proxy\dx_proxy.h"
$File "dxincludeimpl.h"
$File "filememcache.h"
}
$Folder "Link Libraries"
{
-$File "$SRCDIR\lib\public\tier0.lib"
-$File "$SRCDIR\lib\public\tier1.lib"
-$File "$SRCDIR\lib\public\vstdlib.lib"
}
}

View File

@@ -0,0 +1,17 @@
//
// dx_proxy_dx10_v00_pc.vpc
//
// Base script for generating dx_proxy.dll for specific
// version of Microsoft DirectX SDK:
// DirectX10 from April 2007 SDK
//
$Macro SRCDIR "..\.."
$Macro OUTBINDIR "$SRCDIR\dx10sdk\utilities\dx10_40"
$Macro DX_SDK_VER "DX10_V00_PC"
$Include "dx_proxy_base.vpc"
$Project "DX_Proxy ($DX_SDK_VER)"
{
}

View File

@@ -0,0 +1,17 @@
//
// dx_proxy_dx9_v00_pc.vpc
//
// Base script for generating dx_proxy.dll for specific
// version of Microsoft DirectX SDK:
// DirectX9 - oldest legacy version
//
$Macro SRCDIR "..\.."
$Macro OUTBINDIR "$SRCDIR\dx9sdk\utilities"
$Macro DX_SDK_VER "DX9_V00_PC"
$Include "dx_proxy_base.vpc"
$Project "DX_Proxy ($DX_SDK_VER)"
{
}

View File

@@ -0,0 +1,55 @@
//
// dx_proxy_dx9_v00_x360.vpc
//
// Base script for generating dx_proxy.dll for specific
// version of Microsoft DirectX SDK:
// DirectX9 XBox 360 XDK
//
$Macro SRCDIR "..\.."
$Macro OUTBINDIR "$SRCDIR\x360xdk\bin\win32"
$Macro DX_SDK_VER "DX9_V00_X360"
$Include "dx_proxy_base.vpc"
$Configuration
{
$Compiler
{
$AdditionalIncludeDirectories "$BASE;$(XEDK)\include\win32"
}
$Linker
{
$AdditionalLibraryDirectories "$BASE;$(XEDK)\lib\win32\vs2010"
}
}
$Configuration "Debug"
{
$Linker
{
$AdditionalDependencies "$BASE d3d9d.lib d3dx9d.lib xgraphicsd.lib"
}
$Compiler
{
$PreprocessorDefinitions "$BASE;_HAS_ITERATOR_DEBUGGING=1" // _HAS_ITERATOR_DEBUGGING=0 was in source_dll_win32_debug.vpc, but we need it to be 1
// to work with DirectX debug libs. This builds fine for me, and AaronS agrees overriding
// the value here is a better pattern than manually copying everything from all included
// vpc scripts. However, neither of us would be surprised if this breaks.
// -Ted Rivera
}
}
$Configuration "Release"
{
$Linker
{
$AdditionalDependencies "$BASE d3d9.lib d3dx9.lib xgraphics.lib"
}
}
$Project "DX_Proxy ($DX_SDK_VER)"
{
}

View File

@@ -0,0 +1,17 @@
//
// dx_proxy_dx9_v30_pc.vpc
//
// Base script for generating dx_proxy.dll for specific
// version of Microsoft DirectX SDK:
// DirectX9 ver 33 from April 2007 SDK
//
$Macro SRCDIR "..\.."
$Macro OUTBINDIR "$SRCDIR\dx10sdk\utilities\dx9_30"
$Macro DX_SDK_VER "DX9_V30_PC"
$Include "dx_proxy_base.vpc"
$Project "DX_Proxy ($DX_SDK_VER)"
{
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,34 @@
//
// dx_proxy_dx9_v30_pc.vpc
//
// Base script for generating dx_proxy.dll for specific
// version of Microsoft DirectX SDK:
// DirectX9 ver 33 from April 2007 SDK
//
$Macro SRCDIR "..\.."
$Macro OUTBINDIR "$SRCDIR\ps3sdk\utilities"
$Macro DX_SDK_VER "DX_PS3"
$Include "dx_proxy_base.vpc"
$Configuration
{
$Compiler
{
$AdditionalIncludeDirectories "$BASE;$SRCDIR\ps3sdk\cell\host-win32\cg\include;$SRCDIR\ps3sdk\cell\host-common\include"
}
$Linker
{
$AdditionalDependencies "$BASE $SRCDIR\ps3sdk\cell\host-win32\cg\lib\libcgc.lib $SRCDIR\dx10sdk\Lib\x86\dxguid.lib $SRCDIR\ps3sdk\cell\host-win32\cg\lib\SCEShaderPerf.lib"
}
}
$Project "DX_Proxy ($DX_SDK_VER)"
{
$Folder "Source Files"
{
-$File "dx_proxy.cpp"
$File "dx_proxy_ps3.cpp"
}
}

View File

@@ -0,0 +1,52 @@
//====== Copyright c 1996-2007, Valve Corporation, All rights reserved. =======//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
#ifndef DXINCLUDEIMPL_H
#define DXINCLUDEIMPL_H
#ifdef _WIN32
#pragma once
#endif
FileCache s_incFileCache;
struct DxIncludeImpl : public ID3DXInclude
{
STDMETHOD(Open)(THIS_ D3DXINCLUDE_TYPE IncludeType, LPCSTR pFileName, LPCVOID pParentData, LPCVOID *ppData, UINT *pBytes)
{
CachedFileData *pFileData = s_incFileCache.Get( pFileName );
if ( !pFileData || !pFileData->IsValid() )
return E_FAIL;
*ppData = pFileData->GetDataPtr();
*pBytes = pFileData->GetDataLen();
pFileData->UpdateRefCount( +1 );
return S_OK;
}
STDMETHOD(Open)(THIS_ D3DXINCLUDE_TYPE IncludeType, LPCSTR pFileName, LPCVOID pParentData,
LPCVOID *ppData, UINT *pBytes,
/* OUT */ LPSTR pFullPath, DWORD cbFullPath)
{
if ( pFullPath && cbFullPath ) strncpy( pFullPath, pFileName, cbFullPath );
return Open( IncludeType, pFileName, pParentData, ppData, pBytes );
}
STDMETHOD(Close)(THIS_ LPCVOID pData)
{
if ( CachedFileData *pFileData = CachedFileData::GetByDataPtr( pData ) )
pFileData->UpdateRefCount( -1 );
return S_OK;
}
};
DxIncludeImpl s_incDxImpl;
#endif // #ifndef DXINCLUDEIMPL_H

View File

@@ -0,0 +1,118 @@
//====== Copyright c 1996-2007, Valve Corporation, All rights reserved. =======//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
#include "filememcache.h"
namespace {
unsigned long s_ulCachedFileSignature = 0xCACEF11E;
};
//
// Cached file data implementation
//
CachedFileData * CachedFileData::Create( char const *szFilename )
{
FILE *f = fopen( szFilename, "rb" );
int nSize = -1;
if ( f )
{
fseek( f, 0, SEEK_END );
nSize = ftell( f );
fseek( f, 0, SEEK_SET );
}
CachedFileData *pData = ( CachedFileData * ) malloc( eHeaderSize + MAX( nSize + 1, 0 ) );
strcpy( pData->m_chFilename, szFilename );
pData->m_numRefs = 0;
pData->m_numDataBytes = nSize;
pData->m_signature = s_ulCachedFileSignature;
if ( f )
{
fread( pData->m_data, 1, nSize, f );
pData->m_data[nSize] = '\0';
fclose( f );
}
return pData;
}
void CachedFileData::Free( void )
{
free( this );
}
CachedFileData *CachedFileData::GetByDataPtr( void const *pvDataPtr )
{
unsigned char const *pbBuffer = reinterpret_cast< unsigned char const * >( pvDataPtr );
// Assert( pbBuffer );
CachedFileData const *pData = reinterpret_cast< CachedFileData const * >( pbBuffer - eHeaderSize );
// Assert( pData->m_signature == s_ulCachedFileSignature );
return const_cast< CachedFileData * >( pData );
}
char const * CachedFileData::GetFileName() const
{
return m_chFilename;
}
void const * CachedFileData::GetDataPtr() const
{
return m_data;
}
int CachedFileData::GetDataLen() const
{
return MAX( m_numDataBytes, 0 );
}
bool CachedFileData::IsValid() const
{
return ( m_numDataBytes >= 0 );
}
//
// File cache implementation
//
FileCache::FileCache()
{
NULL;
}
CachedFileData * FileCache::Get( char const *szFilename )
{
// Search the cache first
Mapping::iterator it = m_map.find( szFilename );
if ( it != m_map.end() )
return it->second;
// Create the cached file data
CachedFileData *pData = CachedFileData::Create( szFilename );
if ( pData )
m_map.insert( Mapping::value_type( pData->GetFileName(), pData ) );
return pData;
}
void FileCache::Clear()
{
for ( Mapping::iterator it = m_map.begin(), itEnd = m_map.end(); it != itEnd; ++ it )
{
it->second->Free();
}
m_map.clear();
}

View File

@@ -0,0 +1,68 @@
//====== Copyright c 1996-2007, Valve Corporation, All rights reserved. =======//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
#ifndef FILEMEMCACHE_H
#define FILEMEMCACHE_H
#ifdef _WIN32
#pragma once
#endif
#include "tier0/platform.h"
#include "tier0/basetypes.h"
#define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS
#include <hash_map>
#pragma warning ( disable : 4200 )
class CachedFileData
{
friend class FileCache;
protected: // Constructed by FileCache
CachedFileData() {}
static CachedFileData *Create( char const *szFilename );
void Free( void );
public:
static CachedFileData *GetByDataPtr( void const *pvDataPtr );
char const * GetFileName() const;
void const * GetDataPtr() const;
int GetDataLen() const;
int UpdateRefCount( int iDeltaRefCount ) { return m_numRefs += iDeltaRefCount; }
bool IsValid() const;
protected:
enum { eHeaderSize = 256 };
char m_chFilename[256 - 12];
int m_numRefs;
int m_numDataBytes;
int m_signature;
unsigned char m_data[0]; // file data spans further
};
class FileCache
{
public:
FileCache();
~FileCache() { Clear(); }
public:
CachedFileData *Get( char const *szFilename );
void Clear( void );
protected:
struct icmp { bool operator()( char const *x, char const *y ) const { return _stricmp( x, y ) < 0; } };
typedef stdext::hash_map< char const *, CachedFileData *, stdext::hash_compare< char const *, icmp > > Mapping;
Mapping m_map;
};
#endif // #ifndef FILEMEMCACHE_H