mirror of
https://github.com/alliedmodders/hl2sdk.git
synced 2025-09-19 12:06:07 +08:00
Minor IFileSystem & CBufferString updates (#192)
This commit is contained in:

committed by
GitHub

parent
3864058382
commit
b02746e648
@ -24,6 +24,7 @@
|
||||
#include "tier1/bufferstring.h"
|
||||
#include "appframework/IAppSystem.h"
|
||||
#include "tier2/tier2.h"
|
||||
#include "steam/isteamremotestorage.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Forward declarations
|
||||
@ -98,9 +99,10 @@ enum FileWarningLevel_t
|
||||
// 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_NONE = 0, // no filtering, all search path types match
|
||||
FILTER_CULLLOCALIZED = 1,
|
||||
FILTER_CULLPACK = 2, // pack based search paths are culled (maps and zips)
|
||||
FILTER_CULLNONPACK = 3, // non-pack based search paths are culled
|
||||
};
|
||||
|
||||
// search path querying (bit flags)
|
||||
@ -235,16 +237,18 @@ enum SearchPathAdd_t
|
||||
PATH_ADD_TO_TAIL_ATINDEX, // First path searched
|
||||
};
|
||||
|
||||
// ??????
|
||||
enum SearchPathPriority_t
|
||||
{
|
||||
PRIORITY_UNKNOWN,
|
||||
SEARCH_PATH_PRIORITY_DEFAULT = 0,
|
||||
SEARCH_PATH_PRIORITY_LOOSE_FILES = 1,
|
||||
SEARCH_PATH_PRIORITY_VPK = 2,
|
||||
};
|
||||
|
||||
// ??????
|
||||
enum GetSearchPathTypes_t
|
||||
{
|
||||
|
||||
GET_SEARCH_PATH_NO_PACK_FILES = 0,
|
||||
GET_SEARCH_PATH_NO_AUTO_MOUNTED = 1,
|
||||
GET_SEARCH_PATH_ALL = 2,
|
||||
};
|
||||
|
||||
enum FilesystemOpenExFlags_t
|
||||
@ -402,48 +406,6 @@ public:
|
||||
#define DLCFLAGS_PRESENCE_ONLY 0x0001 // causes no search path loadout
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Base file system interface
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// This is the minimal interface that can be implemented to provide access to
|
||||
// a named set of files.
|
||||
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 *pathID = 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( FileHandle_t file ) = 0;
|
||||
virtual unsigned int Size( const char *pFileName, const char *pPathID = 0 ) = 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, CUtlBuffer &buf, int nMaxBytes = 0, int nStartingByte = 0, FSAllocFunc_t pfnAlloc = NULL ) = 0;
|
||||
virtual bool WriteFile( const char *pFileName, const char *pPath, CUtlBuffer &buf ) = 0;
|
||||
virtual bool UnzipFile( const char *pFileName, const char *pPath, const char *pDestination ) = 0;
|
||||
virtual bool CopyAFile( const char *pFileName, const char *pPath, const char *pDestination, bool bDontOverwrite = false ) = 0;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Main file system interface
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -463,8 +425,8 @@ public:
|
||||
|
||||
virtual void Seek(FileHandle_t file, int pos, FileSystemSeek_t seekType) = 0;
|
||||
virtual unsigned int Tell(FileHandle_t file) = 0;
|
||||
virtual unsigned int Size(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;
|
||||
@ -478,18 +440,18 @@ public:
|
||||
//--------------------------------------------------------
|
||||
// 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, CUtlBuffer &buf, int nMaxBytes = 0, int nStartingByte = 0, FSAllocFunc_t pfnAlloc = NULL) = 0;
|
||||
virtual bool WriteFile(const char *pFileName, const char *pPath, CUtlBuffer &buf) = 0;
|
||||
virtual bool UnzipFile(const char *pFileName, const char *pPath, const char *pDestination) = 0;
|
||||
virtual bool CopyAFile(const char *pFileName, const char *pPath, const char *pDestination, bool bDontOverwrite = false) = 0;
|
||||
virtual bool ReadFile(const char *pFileName, const char *pPathID, CUtlBuffer &buf, int nMaxBytes = 0, int nStartingByte = 0, FSAllocFunc_t pfnAlloc = NULL) = 0;
|
||||
virtual bool WriteFile(const char *pFileName, const char *pPathID, CUtlBuffer &buf) = 0;
|
||||
virtual bool UnzipFile(const char *pFileName, const char *pPathID, const char *pDestination) = 0;
|
||||
virtual bool CopyAFile(const char *pFileName, const char *pPathID, const char *pDestination, bool bDontOverwrite = false) = 0;
|
||||
|
||||
virtual void unk001( FileHandle_t, bool ) = 0;
|
||||
virtual void unk001( const char *pFileName, void *pPathID, bool ) = 0;
|
||||
|
||||
//--------------------------------------------------------
|
||||
// Search path manipulation
|
||||
//--------------------------------------------------------
|
||||
|
||||
virtual void unk001() = 0;
|
||||
virtual void unk002() = 0;
|
||||
|
||||
// Add paths in priority order (mod dir, game dir, ....)
|
||||
// If one or more .pak files are in the specified directory, then they are
|
||||
// added after the file system path
|
||||
@ -497,7 +459,7 @@ public:
|
||||
// override is cleared and the current .bsp is searched for an embedded PAK file
|
||||
// and this file becomes the highest priority search path ( i.e., it's looked at first
|
||||
// even before the mod's file system path ).
|
||||
virtual void AddSearchPath( const char *pPath, const char *pathID, SearchPathAdd_t addType = PATH_ADD_TO_TAIL, SearchPathPriority_t priority = PRIORITY_UNKNOWN ) = 0;
|
||||
virtual void AddSearchPath( const char *pPath, const char *pathID, SearchPathAdd_t addType = PATH_ADD_TO_TAIL, SearchPathPriority_t priority = SEARCH_PATH_PRIORITY_DEFAULT, int unknown = 0 ) = 0;
|
||||
virtual bool RemoveSearchPath( const char *pPath, const char *pathID = 0 ) = 0;
|
||||
|
||||
virtual SearchPathStateHandle_t *SaveSearchPathState( const char *pszName ) const = 0;
|
||||
@ -527,8 +489,10 @@ public:
|
||||
// Returns the nSearchPathsToGet amount of paths, each path is separated by ;s. Returns true if pathID has any paths
|
||||
virtual bool GetSearchPath( const char *pathID, GetSearchPathTypes_t pathType, CBufferString &pPath, int nSearchPathsToGet ) = 0;
|
||||
|
||||
virtual void unk003() = 0;
|
||||
virtual void unk004() = 0;
|
||||
// Returns a class or struct instance by value
|
||||
virtual void unk003( const char *pFileName, const char *pPathID ) = 0;
|
||||
|
||||
virtual void unk004( int, CBufferString & ) = 0;
|
||||
|
||||
//--------------------------------------------------------
|
||||
// File manipulation operations
|
||||
@ -542,8 +506,7 @@ public:
|
||||
|
||||
// create a local directory structure
|
||||
virtual void CreateDirHierarchy( const char *path, const char *pathID = 0 ) = 0;
|
||||
|
||||
virtual void unk005() = 0;
|
||||
virtual void CreateDirHierarchyForFile( const char *pFileName, const char *pathID ) = 0;
|
||||
|
||||
// File I/O and info
|
||||
virtual bool IsDirectory( const char *pFileName, const char *pathID = 0 ) = 0;
|
||||
@ -641,13 +604,14 @@ public:
|
||||
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 bool LoadKeyValues( KeyValues& head, KeyValuesPreloadType_t type, char const *filename, char const *pPathID = 0 ) = 0;
|
||||
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;
|
||||
|
||||
@ -723,41 +687,24 @@ public:
|
||||
virtual int GetWhitelistSpewFlags() = 0;
|
||||
virtual void SetWhitelistSpewFlags( int flags ) = 0;
|
||||
|
||||
// Installs a callback used to display a dirty disk dialog
|
||||
// virtual void InstallDirtyDiskReportFunc( FSDirtyDiskReportFunc_t func ) = 0;
|
||||
virtual void GetSearchPathID( CBufferString &inout ) = 0;
|
||||
|
||||
// virtual bool IsLaunchedFromXboxHDD() = 0;
|
||||
// virtual bool IsInstalledToXboxHDDCache() = 0;
|
||||
// virtual bool IsDVDHosted() = 0;
|
||||
// virtual bool IsInstallAllowed() = 0;
|
||||
// File path is "ugc:<UGCHandle_t value>"
|
||||
virtual void AddUGCVPKFile( const char *pszName, const char *pPathID, SearchPathAdd_t addType = PATH_ADD_TO_TAIL ) = 0;
|
||||
virtual void RemoveUGCVPKFile( const char *pszName ) = 0;
|
||||
virtual bool IsUGCVPKFileLoaded( const char *pszName ) = 0;
|
||||
|
||||
virtual int GetSearchPathID( char *pPath, int nMaxLen ) = 0;
|
||||
|
||||
// virtual bool FixupSearchPathsAfterInstall() = 0;
|
||||
// virtual FSDirtyDiskReportFunc_t GetDirtyDiskReportFunc() = 0;
|
||||
|
||||
virtual void AddVPKFile( const char *pszName, const char *, SearchPathAdd_t addType = PATH_ADD_TO_TAIL ) = 0;
|
||||
virtual void RemoveVPKFile( const char *pszName, const char * ) = 0;
|
||||
virtual bool IsVPKFileLoaded( const char *pszName ) = 0;
|
||||
virtual void EnableAutoVPKFileLoading( bool ) = 0;
|
||||
virtual void GetAutoVPKFileLoading( void ) = 0;
|
||||
virtual bool GetAutoVPKFileLoading( void ) = 0;
|
||||
virtual bool ValidateLoadedVPKs( void ) = 0;
|
||||
|
||||
virtual void unk009() = 0;
|
||||
virtual void unk010() = 0;
|
||||
virtual void unk011() = 0;
|
||||
virtual void unk012() = 0;
|
||||
virtual void LoadUGC( UGCHandle_t ugcId, const char *pFilename, const char *pPathID ) = 0;
|
||||
virtual void UnloadUGC( UGCHandle_t ugcId, const char *pPathID ) = 0;
|
||||
virtual bool IsUGCLoaded( UGCHandle_t ugcId ) const = 0;
|
||||
|
||||
/*
|
||||
//These doesn't particularly match the up to date binary, but leaving a note that they were here before!
|
||||
|
||||
virtual void AddUGCVPKFile( uint64 ugcId, const char *, SearchPathAdd_t ) = 0;
|
||||
virtual void RemoveUGCVPKFile( uint64 ugcId, const char * ) = 0;
|
||||
virtual bool IsUGCVPKFileLoaded( uint64 ugcId ) = 0;
|
||||
*/
|
||||
|
||||
virtual void ParseUGCHandleFromFilename( const char *, char ** )const = 0;
|
||||
virtual void CreateFilenameForUGCFile( char *, int, uint64 ugcId, const char *, char ) const = 0;
|
||||
virtual void OpenUGCFile( uint64 ugcId ) = 0;
|
||||
virtual UGCHandle_t ParseUGCHandleFromFilename( const char *pFileName, char **ppRemainingFilename = nullptr ) const = 0;
|
||||
virtual void CreateFilenameForUGCFile( CBufferString &out, UGCHandle_t ugcId, const char *pExtension, char separator = CORRECT_PATH_SEPARATOR ) const = 0;
|
||||
virtual FileHandle_t OpenUGCFile( UGCHandle_t ugcId ) = 0;
|
||||
|
||||
// call this to look for CPU-hogs during loading processes. When you set this, a breakpoint
|
||||
// will be issued whenever the indicated # of seconds go by without an i/o request. Passing
|
||||
|
@ -79,15 +79,18 @@ public:
|
||||
|
||||
DLL_CLASS_IMPORT const char *AppendRepeat(char cChar, int nChars, bool bIgnoreAlignment = false);
|
||||
|
||||
// Given a path and a filename, composes "path\filename", inserting the (OS correct) separator if necessary
|
||||
DLL_CLASS_IMPORT const char *ComposeFileName(const char *pPath, const char *pFile, char cSeparator);
|
||||
|
||||
DLL_CLASS_IMPORT const char *ConvertIn(unsigned int const *pData, int nSize, bool bIgnoreAlignment = false);
|
||||
DLL_CLASS_IMPORT const char *ConvertIn(wchar_t const *pData, int nSize, bool bIgnoreAlignment = false);
|
||||
|
||||
DLL_CLASS_IMPORT const char *DefaultExtension(const char *pExt);
|
||||
// Make path end with extension if it doesn't already have an extension
|
||||
DLL_CLASS_IMPORT const char *DefaultExtension(const char *extension);
|
||||
|
||||
DLL_CLASS_IMPORT bool EndsWith(const char *pMatch) const;
|
||||
DLL_CLASS_IMPORT bool EndsWith_FastCaseInsensitive(const char *pMatch) const;
|
||||
// Does string end with 'pSuffix'? (case sensitive/insensitive variants)
|
||||
DLL_CLASS_IMPORT bool EndsWith(const char *pSuffix) const;
|
||||
DLL_CLASS_IMPORT bool EndsWith_FastCaseInsensitive(const char *pSuffix) const;
|
||||
|
||||
// Ensures the nCapacity condition is met and grows the local buffer if needed.
|
||||
// Returns pResultingBuffer pointer to the newly allocated data, as well as resulting capacity that was allocated in bytes.
|
||||
@ -102,11 +105,20 @@ public:
|
||||
DLL_CLASS_IMPORT const char *ExtendPath(const char *pPath, char cSeparator);
|
||||
|
||||
DLL_CLASS_IMPORT const char *ExtractFileBase(const char *pPath);
|
||||
|
||||
// Copy out the file extension into dest
|
||||
DLL_CLASS_IMPORT const char *ExtractFileExtension(const char *pPath);
|
||||
|
||||
// Copy out the path except for the stuff after the final pathseparator
|
||||
DLL_CLASS_IMPORT const char *ExtractFilePath(const char *pPath, bool);
|
||||
|
||||
|
||||
DLL_CLASS_IMPORT const char *ExtractFirstDir(const char *pPath);
|
||||
|
||||
// Force slashes of either type to be = separator character
|
||||
DLL_CLASS_IMPORT const char *FixSlashes(char cSeparator = CORRECT_PATH_SEPARATOR);
|
||||
|
||||
// Fixes up a file name, removing dot slashes, fixing slashes, converting to lowercase, etc.
|
||||
DLL_CLASS_IMPORT const char *FixupPathName(char cSeparator);
|
||||
|
||||
DLL_CLASS_IMPORT int Format(const char *pFormat, ...) FMTFUNCTION(2, 3);
|
||||
@ -127,11 +139,18 @@ public:
|
||||
|
||||
DLL_CLASS_IMPORT int GrowByChunks(int, int);
|
||||
|
||||
// Wrapper around V_MakeAbsolutePath()
|
||||
// If pPath is a relative path, this function makes it into an absolute path
|
||||
// using the current working directory as the base, or pStartingDir if it's non-NULL.
|
||||
// Returns NULL if it runs out of room in the string, or if pPath tries to ".." past the root directory.
|
||||
DLL_CLASS_IMPORT const char *MakeAbsolutePath(const char *pPath, const char *pStartingDir);
|
||||
// Wrapper around V_MakeAbsolutePath() but also does separator fixup
|
||||
|
||||
// Same as MakeAbsolutePath, but also does separator fixup
|
||||
DLL_CLASS_IMPORT const char *MakeFixedAbsolutePath(const char *pPath, const char *pStartingDir, char cSeparator = CORRECT_PATH_SEPARATOR);
|
||||
// Wrapper around V_MakeRelativePath()
|
||||
|
||||
// Creates a relative path given two full paths
|
||||
// The first is the full path of the file to make a relative path for.
|
||||
// The second is the full path of the directory to make the first file relative to
|
||||
// Returns NULL if they can't be made relative (on separate drives, for example)
|
||||
DLL_CLASS_IMPORT const char *MakeRelativePath(const char *pFullPath, const char *pDirectory);
|
||||
|
||||
DLL_CLASS_IMPORT void MoveFrom(CBufferString &pOther);
|
||||
@ -161,8 +180,8 @@ public:
|
||||
|
||||
DLL_CLASS_IMPORT const char *ReverseChars(int nIndex, int nChars);
|
||||
|
||||
// Appends the pExt to the local buffer, also appends '.' in between even if it wasn't provided in pExt.
|
||||
DLL_CLASS_IMPORT const char *SetExtension(const char *pExt);
|
||||
// Strips any current extension from path and ensures that extension is the new extension
|
||||
DLL_CLASS_IMPORT const char *SetExtension(const char *extension);
|
||||
|
||||
DLL_CLASS_IMPORT char *SetLength(int nLen, bool bIgnoreAlignment = false, int *pNewCapacity = NULL);
|
||||
DLL_CLASS_IMPORT void SetPtr(char *pBuf, int nBufferChars, int, bool, bool);
|
||||
|
Reference in New Issue
Block a user