uid issue

This commit is contained in:
KittenPopo
2021-07-24 21:11:47 -07:00
commit c2130ba4e9
13850 changed files with 6241419 additions and 0 deletions

View File

@ -0,0 +1,164 @@
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose:
//
//===========================================================================//
#ifndef QUEUEDLOADER_H
#define QUEUEDLOADER_H
#ifdef _WIN32
#pragma once
#endif
#include "tier0/platform.h"
#include "appframework/iappsystem.h"
enum LoaderError_t
{
LOADERERROR_NONE = 0,
LOADERERROR_FILEOPEN = -1,
LOADERERROR_READING = -2,
};
enum LoaderPriority_t
{
LOADERPRIORITY_ANYTIME = 0, // low priority, job can finish during gameplay
LOADERPRIORITY_BEFOREPLAY = 1, // job must complete before load ends
LOADERPRIORITY_DURINGPRELOAD = 2, // job must be complete during preload phase
};
typedef void ( *QueuedLoaderCallback_t )( void *pContext, void *pContext2, const void *pData, int nSize, LoaderError_t loaderError );
struct LoaderJob_t
{
LoaderJob_t()
{
memset( this, 0, sizeof( *this ) );
}
const char *m_pFilename; // path to resource
const char *m_pPathID; // optional, can be NULL
QueuedLoaderCallback_t m_pCallback; // called at i/o delivery
void *m_pContext; // caller provided data
void *m_pContext2; // caller provided data
void *m_pTargetData; // optional, caller provided target buffer
int m_nBytesToRead; // optional read clamp, otherwise 0
unsigned int m_nStartOffset; // optional start offset, otherwise 0
LoaderPriority_t m_Priority; // data must arrive by specified interval
bool m_bPersistTargetData; // caller wants ownership of i/o buffer
bool m_bAnonymousDecode; // anonymous job wants a lzma decode
};
enum ResourcePreload_t
{
RESOURCEPRELOAD_UNKNOWN,
RESOURCEPRELOAD_SOUND,
RESOURCEPRELOAD_MATERIAL,
RESOURCEPRELOAD_MODEL,
RESOURCEPRELOAD_CUBEMAP,
RESOURCEPRELOAD_STATICPROPLIGHTING,
RESOURCEPRELOAD_GPUBUFFERALLOCATOR,
RESOURCEPRELOAD_ANONYMOUS,
RESOURCEPRELOAD_COUNT
};
abstract_class IResourcePreload
{
public:
// Sent as a warning shot. Some callers may choose to do pre-emptive purging.
virtual void PrepareForCreate( bool bSameMap ) = 0;
// Called during preload phase for ALL the resources expected by the level.
// Caller should not do i/o but generate AddJob() requests. Resources that already exist
// and are not referenced by this function would be candidates for purge.
virtual bool CreateResource( const char *pName ) = 0;
// Sent as an event hint during preload, that creation has completed, AddJob() i/o is about to commence.
// Caller should purge any unreferenced resources before the AddJobs are performed.
// "Must Complete" data will be guaranteed finished, at preload conclusion, before the normal load phase commences.
virtual void PurgeUnreferencedResources() = 0;
// Sent as an event hint that gameplay rendering is imminent.
// Low priority jobs may still be in async flight.
virtual void OnEndMapLoading( bool bAbort ) = 0;
virtual void PurgeAll() = 0;
#if defined( _PS3 )
virtual bool RequiresRendererLock() = 0;
#endif // _PS3
};
// Default implementation
class CResourcePreload : public IResourcePreload
{
void PrepareForCreate( bool bSameMap ) {}
void PurgeUnreferencedResources() {}
void OnEndMapLoading( bool bAbort ) {}
void PurgeAll() {}
#if defined( _PS3 )
virtual bool RequiresRendererLock() { return false; }
#endif // _PS3
};
// UI can install progress notification
abstract_class ILoaderProgress
{
public:
// implementation must ignore UpdateProgress() if not scoped by Begin/End
virtual void BeginProgress() = 0;
virtual void EndProgress() = 0;
virtual void UpdateProgress( float progress, bool bForce = false ) = 0;
virtual void PauseNonInteractiveProgress( bool bPause ) = 0;
};
// spew detail
#define LOADER_DETAIL_NONE 0
#define LOADER_DETAIL_TIMING (1<<0)
#define LOADER_DETAIL_COMPLETIONS (1<<1)
#define LOADER_DETAIL_LATECOMPLETIONS (1<<2)
#define LOADER_DETAIL_PURGES (1<<3)
#define LOADER_DETAIL_CREATIONS (1<<3)
abstract_class IQueuedLoader : public IAppSystem
{
public:
virtual void InstallLoader( ResourcePreload_t type, IResourcePreload *pLoader ) = 0;
virtual void InstallProgress( ILoaderProgress *pProgress ) = 0;
// Set bOptimizeReload if you want appropriate data (such as static prop lighting)
// to persist - rather than being purged and reloaded - when going from map A to map A.
virtual bool BeginMapLoading( const char *pMapName, bool bLoadForHDR, bool bOptimizeMapReload, void (*pfnBeginMapLoadingCallback)( int nStage ) ) = 0;
virtual void EndMapLoading( bool bAbort ) = 0;
virtual bool AddJob( const LoaderJob_t *pLoaderJob ) = 0;
// injects a resource into the map's reslist, rejected if not understood
virtual void AddMapResource( const char *pFilename ) = 0;
// callback is asynchronous
virtual bool ClaimAnonymousJob( const char *pFilename, QueuedLoaderCallback_t pCallback, void *pContext, void *pContext2 = NULL ) = 0;
// provides data if loaded, caller owns data
virtual bool ClaimAnonymousJob( const char *pFilename, void **pData, int *pDataSize, LoaderError_t *pError = NULL ) = 0;
virtual bool IsMapLoading() const = 0;
virtual bool IsSameMapLoading() const = 0;
virtual bool IsFinished() const = 0;
// callers can expect that jobs are not immediately started when batching
virtual bool IsBatching() const = 0;
// callers can conditionalize operational spew
virtual int GetSpewDetail() const = 0;
virtual void PurgeAll( ResourcePreload_t *pDontPurgeList = NULL, int nPurgeListSize = 0 ) = 0;
#ifdef _PS3
// hack to prevent PS/3 deadlock on queued loader render mutex when quitting during loading a map
virtual uint UnlockProgressBarMutex() = 0;
virtual void LockProgressBarMutex( uint nLockCount ) = 0;
#endif
};
DECLARE_TIER2_INTERFACE( IQueuedLoader, g_pQueuedLoader );
#endif // QUEUEDLOADER_H

View File

@ -0,0 +1,89 @@
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose:
//
//===========================================================================//
#ifndef XBOXINSTALLER_H
#define XBOXINSTALLER_H
#include "tier0/platform.h"
#if defined( PLATFORM_X360 )
#ifdef _WIN32
#pragma once
#endif
#include "appframework/iappsystem.h"
#define SOURCE_SECTOR_SIZE 2048 // DVD Sector Size
#define TARGET_SECTOR_SIZE 512 // HDD Sector Size
// all CStrike15 cached files relative to this, having a parent dir is critical
// the cache is a shared resource among titles, using the simple root would be VERY bad
#define CACHE_PATH_CSTIKRE15 "cache:/cs1501"
struct CopyStats_t
{
DWORD m_InstallStartTime;
DWORD m_InstallStopTime;
char m_srcFilename[MAX_PATH];
char m_dstFilename[MAX_PATH];
DWORD m_ReadSize;
DWORD m_WriteSize;
DWORD m_BytesCopied;
DWORD m_TotalReadTime;
DWORD m_TotalWriteTime;
DWORD m_TotalReadSize;
DWORD m_TotalWriteSize;
DWORD m_BufferReadSize;
DWORD m_BufferWriteSize;
DWORD m_BufferReadTime;
DWORD m_BufferWriteTime;
DWORD m_CopyTime;
DWORD m_CopyErrors;
DWORD m_NumReadBuffers;
DWORD m_NumWriteBuffers;
};
abstract_class IXboxInstaller : public IAppSystem
{
public:
virtual bool Setup( bool bForceInstall = false ) = 0;
virtual void ResetSetup() = 0;
virtual bool Start() = 0;
virtual void Stop() = 0;
virtual bool IsStopped( bool bForceStop ) = 0;
virtual DWORD GetTotalSize() = 0;
virtual DWORD GetVersion() = 0;
virtual const CopyStats_t *GetCopyStats() = 0;
virtual bool IsInstallEnabled() = 0;
virtual bool IsFullyInstalled() = 0;
// hint to the other systems that may allow a restart
virtual bool ShouldRestart() = 0;
// prefer a restart, but until that happens...
// called by other systems when safe to alter search paths
virtual bool ForceCachePaths() = 0;
virtual void SpewStatus() = 0;
};
DECLARE_TIER1_INTERFACE( IXboxInstaller, g_pXboxInstaller );
extern bool IsAlreadyInstalledToXboxHDDCache();
#endif // _X360
#endif // XBOXINSTALLER_H

View File

@ -0,0 +1,559 @@
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose: Provides IAsyncFileRequest and IAsyncFileSystem Interfaces
// and supporting objects and values
//
// $NoKeywords: $
//===========================================================================//
#ifndef IASYNCFILESYSTEM_H
#define IASYNCFILESYSTEM_H
#ifdef _WIN32
#pragma once
#endif
#include <limits.h>
#include "tier0/threadtools.h"
#include "tier0/memalloc.h"
#include "tier0/tslist.h"
#include "tier1/interface.h"
#include "tier1/utlsymbol.h"
#include "tier1/functors.h"
#include "tier1/checksum_crc.h"
#include "tier1/utlqueue.h"
#include "appframework/iappsystem.h"
#include "tier2/tier2.h"
//-----------------------------------------------------------------------------
// "New" (circa 2009) Async FileSystem Interface
//-----------------------------------------------------------------------------
// This is a "newer" asynchronous-only file system interface. Using the
// global that exposes it is intended to guarantee that no file I/O operations
// will be blocking (unless you submit them synchronously).
//
//-----------------------------------------------------------------------------
// Forward declarations we need
//-----------------------------------------------------------------------------
class CIOCompletionQueue;
class IAsyncFileRequest;
class IAsyncSearchRequest;
//-----------------------------------------------------------------------------
// AsyncRequestStatus_t - Contains the success / error status of an
// asynchronous file operation
//-----------------------------------------------------------------------------
enum AsyncRequestStatus_t
{
ASYNC_REQUEST_ERROR_BADPTR = -99, // The request Pointer passed in is bad
ASYNC_REQUEST_ERROR_ALREADYSUBMITTED = -98, // The request was already submitted
ASYNC_REQUEST_ERROR_BADOPER = -97, // The operation type (read, write, append, etc) is invalid
ASYNC_REQUEST_ERROR_BADUSERBUFFER = -96, // The supplied user buffer is incomplete
ASYNC_REQUEST_ERROR_NOBUFFER = -95, // The operation requested requires a valid user buffer
ASYNC_REQUEST_ERROR_NONOTIFICATION = -94, // User did not specify a callback or an IOResultQueue to message
ASYNC_REQUEST_ERROR_NOTSUBMITTED = -93, // The request has not yet been submitted
ASYNC_REQUEST_ERROR_ALREADYSERVICED = -92, // The request has already been serviced
ASYNC_REQUEST_ERROR_PATHTOOLONG = -89, // The filepath+name is too long
ASYNC_REQUEST_ERROR_INVALIDFILENAME = -88, // The Filename contains invalid characters
ASYNC_REQUEST_ERROR_BADPATHSPEC = -87, // adjacent path separators in the filename or ends in path char
ASYNC_REQUEST_ERROR_FILENAMETOOLONG = -86, // the filename is too long...
ASYNC_REQUEST_ERROR_NOTVALIDSYNCRONOUS = -85, // Request (callbacks) not valid in synchronous mode
// these mirror the existing async file system return codes. remove when changed
ASYNC_REQUEST_ERROR_ALIGNMENT = -16, // read parameters invalid for unbuffered IO
ASYNC_REQUEST_ERROR_FAILURE = -15, // hard subsystem failure
ASYNC_REQUEST_ERROR_READING = -14, // read error on file
ASYNC_REQUEST_ERROR_NOMEMORY = -13, // out of memory for file read
ASYNC_REQUEST_ERROR_UNKNOWNID = -12, // caller's provided id is not recognized
ASYNC_REQUEST_ERROR_FILEOPEN = -11, // filename could not be opened (bad path, not exist, etc)
ASYNC_REQUEST_STATUS_UNDEFINED = -1, // should never be this (indicates incomplete code path)
ASYNC_REQUEST_OK = 0, // operation is successful
ASYNC_REQUEST_FORCE_INT32 = INT32_MAX // force AsyncRequestStatus_t to 32 bits
};
//-----------------------------------------------------------------------------
// AsyncRequestState_t - indicates what state / stage of processing that an
// async request is in
//-----------------------------------------------------------------------------
enum AsyncRequestState_t
{
ASYNC_REQUEST_STATE_UNDEFINED = 0, // The request is probably invalid
ASYNC_REQUEST_STATE_COMPOSING = 1, // The request is being composed (open for edit)
ASYNC_REQUEST_STATE_SUBMITTED, // The request is in the priority queue waiting to be serviced
ASYNC_REQUEST_STATE_SERVICING, // The request is being processed by a job thread
ASYNC_REQUEST_STATE_AWATING_FINISH, // The request has completed IO, and waiting to be post-processed by user code
ASYNC_REQUEST_STATE_COMPLETED, // The request has completed all tasks
ASYNC_REQUEST_STATE_FORCE_INT32 = INT32_MAX // force AsyncRequestStatus_t to 32 bits
};
//-----------------------------------------------------------------------------
// AsyncFileOperation_t - list of I/O options the new async system supports
//
//-----------------------------------------------------------------------------
enum AsyncFileOperation_t
{
ASYNC_OP_UNDEFINED = 0, // mapping undefined to 0 so that a value must be set (constructors memsets to 0)
ASYNC_OP_READFILE, // This is a read request
ASYNC_OP_WRITEFILE, // Write data to a file, delete if existing??
ASYNC_OP_APPENDFILE, // Append to end of file, must file exist?
ASYNC_OP_SCANDIR, // Scan a directory looking for name-matched files
ASYNC_OP_COUNT, // Automatic list count
ASYNC_OP_GROUP, // Object is a container of requests
ASYNC_OP_FORCE_INT32 = INT32_MAX
};
//-----------------------------------------------------------------------------
// IAsyncRequestBase - Interface common to all types of
// asynchronous file IO requests
//
//-----------------------------------------------------------------------------
class IAsyncRequestBase
{
friend class CAsyncFileSystem;
friend class CAsyncGroupRequest;
public:
// functions to query operation
virtual AsyncFileOperation_t GetAsyncOperationType() = 0; // Interface to determine what the derived type is
// Completion options
virtual void AssignCallback( CFunctor* pCallback ) = 0; // Add a completion callback to this request
virtual void AssignResultQueue( CIOCompletionQueue* pMsgQueue ) = 0; // Send a completion notification to this queue object
virtual void AssignCallbackAndQueue( CIOCompletionQueue* pMsgQueue, CFunctor* pCallback ) = 0; // assign a callback and a completion queue
// Completion processing functions
virtual void ProcessCallback( bool bReleaseRequest = true ) = 0; // Perform any assigned callbacks
virtual void KeepRequestPostCallback() = 0; // User wants to keep request alive after the callback completes
virtual void DontKeepRequestPostCallback() = 0; // User doesn't want to keep request after the callback completes
virtual void Release() = 0; // lets user manually release the async request (only valid when completed)
// Priority Functions
virtual void SetPriority( int32 nPriority ) = 0; // lets the user set or change the priority of this request
virtual int32 GetPriority() = 0; // queries the priority of this request
// Status & Results functions
virtual AsyncRequestState_t GetRequestState() = 0; // Returns what phase of the Async Process the request is in
virtual AsyncRequestStatus_t GetRequestStatus() = 0; // Returns the error status of the last IO operation performed by this request
private:
virtual class CAsyncRequestBase* GetBase() = 0; // Used internally by the AsyncFileSystem
};
//-----------------------------------------------------------------------------
// IAsyncRequestGroup - Interface for grouping requests together
//
//
//-----------------------------------------------------------------------------
class IAsyncGroupRequest : public IAsyncRequestBase
{
public:
virtual void AddAsyncRequest( IAsyncRequestBase* pRequest ) = 0;
virtual int32 GetAsyncRequestCount() = 0;
virtual IAsyncRequestBase* GetAsyncRequest( int32 nRNum ) = 0;
virtual IAsyncFileRequest* GetAsyncFileRequest( int32 nRNum ) = 0;
virtual IAsyncSearchRequest* GetAsyncSearchRequest( int32 nRNum ) = 0;
virtual void ReleaseAsyncRequest( int32 nRNum ) = 0;
};
//-----------------------------------------------------------------------------
// IAsyncFileRequest - Interface for setting and reading the results of an
// asynchronous file IO request
//
//-----------------------------------------------------------------------------
class IAsyncFileRequest : public IAsyncRequestBase
{
public:
// functions to set filename and operation
virtual void LoadFile( const char* pFileName ) = 0; // make this a 'read data from file' request
virtual void SaveFile( const char* pFileName ) = 0; // make this a 'write data to file' request
virtual void AppendFile( const char* pFileName ) = 0; // make this a 'append data to file' request
virtual void SetFileName( const char* pFileName ) = 0; // assign the filename to use
virtual const char* GetFileName() = 0; // get the filename we've assigned
// Buffer control functions - user supplied data buffer
virtual void SetUserBuffer( void* pDataBuffer, size_t nBufferSize ) = 0; // User supplies a memory buffer to use, which they own the memory for
virtual void* GetUserBuffer() = 0; // returns the address of the user supplied buffer
virtual size_t GetUserBufferSize() = 0; // returns the size of the user supplied buffer
virtual void ProvideDataBuffer() = 0; // Let the async file system provide a buffer to hold the data transferred (valid for Load/Read only)
// Buffer results - the data buffer can be user supplied or async system supplied
virtual void* GetResultBuffer() = 0; // Returns the address of the data transferred
virtual size_t GetResultBufferSize() = 0; // Returns the size of the buffer holding the data transferred
virtual size_t GetIOTransferredSize() = 0; // Returns the number of bytes of data actually transferred
// Memory control functions for buffers allocated by the async file system
virtual void KeepResultBuffer() = 0; // User wants to keeps buffer allocated by the file system
virtual void ReleaseResultBuffer() = 0; // User decides they want the request to take care of releasing the buffer
// file position functions
virtual void ReadFileDataAt( int64 nFileOffset, size_t nReadSize = 0 ) = 0; // Read file data starting at supplied offset, optional max size to read
virtual void WriteFileDataAt( int64 nFileOffset, size_t nWriteSize = 0 ) = 0; // Write data to file at supplied offset, optional size to write (max size of buffer)
};
//-----------------------------------------------------------------------------
// CDirectoryEntryInfo_t - File Information gathered by async directory searches
// Designed to be cross platform
//
//-----------------------------------------------------------------------------
struct CDirectoryEntryInfo_t
{
public:
char m_FullFileName[MAX_PATH];
};
//-----------------------------------------------------------------------------
// IAsyncSearchRequest - Interface for setting and reading the results
// of an asynchronous directory search request
//
//-----------------------------------------------------------------------------
class IAsyncSearchRequest : public IAsyncRequestBase
{
public:
// functions to define the request
virtual void SetSearchFilespec( const char* pFullSearchSpec ) = 0;
virtual void SetSearchPathAndFileSpec( const char* pPathId, const char* pRelativeSearchSpec ) = 0;
virtual void SetSearchPathAndFileSpec( const char* pPathId, const char* pRelativeSearchPath, const char* pSearchSpec ) = 0;
virtual void SetSubdirectoryScan( const bool bInclude ) = 0;
virtual bool GetSubdirectoryScan() = 0;
// Functions to return the results.
virtual int GetResultCount() = 0;
virtual CDirectoryEntryInfo_t* GetResult( int rNum = 0 ) = 0;
virtual const char* GetMatchedFile( int rNum = 0 ) = 0;
};
//-----------------------------------------------------------------------------
// CAsyncIOResult_t - Holds the result of an async file I/O request in a
// CIOCompletionQueue
//-----------------------------------------------------------------------------
struct CAsyncIOResult_t
{
public:
IAsyncRequestBase* m_pRequest; // Handle of the job
AsyncRequestStatus_t m_Status; // Result status
inline CAsyncIOResult_t();
inline void ProcessCallback();
};
//-----------------------------------------------------------------------------
// CAsyncIOResult_t - Inline method Implementations
//
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// CAsyncIOResult_t - Constructor
//-----------------------------------------------------------------------------
inline CAsyncIOResult_t::CAsyncIOResult_t()
{
m_pRequest = NULL;
m_Status = ASYNC_REQUEST_STATUS_UNDEFINED;
}
//-----------------------------------------------------------------------------
// CAsyncIOResult_t - process the user callback
//-----------------------------------------------------------------------------
inline void CAsyncIOResult_t::ProcessCallback()
{
if ( m_pRequest != NULL )
{
m_pRequest->ProcessCallback();
}
}
//-----------------------------------------------------------------------------
// CIOCompletionQueue - Dedicated Queue containing Async IO Notifications
//-----------------------------------------------------------------------------
class CIOCompletionQueue
{
private:
CTSQueue< CAsyncIOResult_t > m_TSIOResultQueue;
public:
inline void Insert( CAsyncIOResult_t& theResult);
inline bool IsEmpty();
inline bool IsNotEmpty();
inline void ProcessAllResultCallbacks();
inline bool RemoveAtHead( CAsyncIOResult_t& theResult );
};
//-----------------------------------------------------------------------------
// CIOCompletionQueue - Inline Implementation
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// CIOCompletionQueue - insert message into queue
//-----------------------------------------------------------------------------
inline void CIOCompletionQueue::Insert( CAsyncIOResult_t& theResult)
{
m_TSIOResultQueue.PushItem( theResult );
}
//-----------------------------------------------------------------------------
// CIOCompletionQueue - check if queue empty
//-----------------------------------------------------------------------------
inline bool CIOCompletionQueue::IsEmpty()
{
return ( m_TSIOResultQueue.Count() == 0 );
}
//-----------------------------------------------------------------------------
// CIOCompletionQueue - check if queue is not empty
//-----------------------------------------------------------------------------
inline bool CIOCompletionQueue::IsNotEmpty()
{
return ( m_TSIOResultQueue.Count() != 0 );
}
//-----------------------------------------------------------------------------
// CIOCompletionQueue constructor
//-----------------------------------------------------------------------------
inline void CIOCompletionQueue::ProcessAllResultCallbacks()
{
CAsyncIOResult_t IOResult;
while ( m_TSIOResultQueue.PopItem( &IOResult ) )
{
IOResult.ProcessCallback(); // no lock needed here, we are outside of the queue
};
}
//-----------------------------------------------------------------------------
// CIOCompletionQueue - pop off the first item
//-----------------------------------------------------------------------------
inline bool CIOCompletionQueue::RemoveAtHead( CAsyncIOResult_t& theResult )
{
return ( m_TSIOResultQueue.PopItem( &theResult ) );
}
//-----------------------------------------------------------------------------
// IAsyncFileSystem - Interface to new async user methods
//
//-----------------------------------------------------------------------------
class IAsyncFileSystem : public IAppSystem
{
public:
//------------------------------------
// Global operations
//------------------------------------
virtual AsyncRequestStatus_t SubmitAsyncFileRequest( const IAsyncRequestBase* pRequest ) = 0;
virtual AsyncRequestStatus_t SubmitSyncFileRequest( const IAsyncRequestBase* pRequest ) = 0;
virtual AsyncRequestStatus_t GetAsyncFileRequestStatus( const IAsyncRequestBase* pRequest ) = 0;
virtual AsyncRequestStatus_t AbortAsyncFileRequest( const IAsyncRequestBase* pRequest ) = 0;
virtual void SuspendAllAsyncIO( bool bWaitForIOCompletion = true ) = 0;
virtual void ResumeAllAsyncIO() = 0;
virtual AsyncRequestStatus_t AbortAllAsyncIO( bool bWaitForIOCompletion = true ) = 0;
virtual IAsyncFileRequest* CreateNewFileRequest() = 0;
virtual IAsyncSearchRequest* CreateNewSearchRequest() = 0;
virtual IAsyncGroupRequest* CreateNewAsyncRequestGroup() = 0;
virtual void ReleaseAsyncRequest( const IAsyncRequestBase* pRequest ) = 0;
virtual bool BlockUntilAsyncIOComplete( const IAsyncRequestBase* pRequest ) = 0;
virtual void* AllocateBuffer( size_t nBufferSize, int nAlignment = 4 ) = 0;
virtual void ReleaseBuffer( void* pBuffer ) = 0;
};
//-----------------------------------------------------------------------------
// Globals Exposed
//-----------------------------------------------------------------------------
DECLARE_TIER2_INTERFACE( IAsyncFileSystem, g_pAsyncFileSystem );
//-----------------------------------------------------------------------------
// New Async Filesystem Request Helpers
//-----------------------------------------------------------------------------
// These are functions that simplify and clarify the setup of common file
// operations in the new asynchronous file system.
//
// Placed inline for linkage convenience
//
// If you have a generic helper you commonly use, add it to this list
//
//-----------------------------------------------------------------------------
// ::AsyncReadFile() - Helper function to setup a New Async Request
// load an entire file file, allocate a buffer, use all other defaults
//-----------------------------------------------------------------------------
inline IAsyncFileRequest* AsyncReadFile( const char* pFileName )
{
IAsyncFileRequest* theRequest = g_pAsyncFileSystem->CreateNewFileRequest(); // Open a new request
theRequest->LoadFile( pFileName ); // specify file and set request type to read
theRequest->ProvideDataBuffer(); // Let the request provide and own the memory
return theRequest; // return request object pointer
}
//-----------------------------------------------------------------------------
// ::AsyncReadFileToBuffer() - Helper function to setup a New Async Request
// load an entire file file, to a supplied buffer, use all defaults
//-----------------------------------------------------------------------------
inline IAsyncFileRequest* AsyncReadFileToBuffer( const char* pFileName, void* pBuffer, size_t nBufferSize )
{
IAsyncFileRequest* theRequest = g_pAsyncFileSystem->CreateNewFileRequest(); // Open a new request
theRequest->LoadFile( pFileName ); // specify file and set request type to read
theRequest->SetUserBuffer( pBuffer, nBufferSize ); // Specify the buffer we are using
return theRequest; // return request object pointer
}
//-----------------------------------------------------------------------------
// ::AsyncReadFileBlock() - Helper function to setup a New Async Request
// load an portion of a file, allocate a buffer, use all defaults
//-----------------------------------------------------------------------------
inline IAsyncFileRequest* AsyncReadFileBlock( const char* pFileName, int64 nOffset, size_t nLoadSize )
{
IAsyncFileRequest* theRequest = g_pAsyncFileSystem->CreateNewFileRequest(); // Open a new request
theRequest->LoadFile( pFileName ); // specify file and set request type to read
theRequest->ReadFileDataAt( nOffset, nLoadSize ); // Specify the part of the file we want to read
theRequest->ProvideDataBuffer(); // Let the request provide and own the memory
return theRequest; // return request object pointer
}
//-----------------------------------------------------------------------------
// ::AsyncReadFileBlockToBuffer() - Helper function to setup a New Async Request
// load an portion of a file, to a supplied buffer, use all defaults
//-----------------------------------------------------------------------------
inline IAsyncFileRequest* AsyncReadFileBlockToBuffer( const char* pFileName, int64 nOffset, size_t nLoadSize, void* pBuffer, size_t nBufferSize )
{
IAsyncFileRequest* theRequest = g_pAsyncFileSystem->CreateNewFileRequest(); // Open a new request
theRequest->LoadFile( pFileName ); // specify file and set request type to read
theRequest->ReadFileDataAt( nOffset, nLoadSize ); // Specify the part of the file we want to read
theRequest->SetUserBuffer( pBuffer, nBufferSize ); // Specify the buffer we are using
return theRequest; // return request object pointer
}
//-----------------------------------------------------------------------------
// ::AsyncWriteBufferToFile() - Helper function to setup a New Async Request
// write a buffer to a file, overwriting existing, use all defaults
//-----------------------------------------------------------------------------
inline IAsyncFileRequest* AsyncWriteBufferToFile( const char* pFileName, void* pBuffer, size_t nBufferSize )
{
IAsyncFileRequest* theRequest = g_pAsyncFileSystem->CreateNewFileRequest(); // Open a new request
theRequest->SaveFile( pFileName ); // Specify file and set request type to write
theRequest->SetUserBuffer( pBuffer, nBufferSize ); // Specify the buffer we are using
return theRequest; // return request object pointer
}
//-----------------------------------------------------------------------------
// ::AsyncAppendBufferToFile() - Helper function to setup a New Async Request
// write a buffer to a file, append to if existing, use all defaults
//-----------------------------------------------------------------------------
inline IAsyncFileRequest* AsyncAppendBufferToFile( const char* pFileName, void* pBuffer, size_t nBufferSize )
{
IAsyncFileRequest* theRequest = g_pAsyncFileSystem->CreateNewFileRequest(); // Open a new request
theRequest->AppendFile( pFileName ); // Specify file and set request type to append data to
theRequest->SetUserBuffer( pBuffer, nBufferSize ); // Specify the buffer we are using
return theRequest; // return request object pointer
}
//-----------------------------------------------------------------------------
// ::AsyncRequestRelease() - Helper function to release Async Request
// calls release, sets the handle to null
//-----------------------------------------------------------------------------
inline void AsyncRequestRelease( IAsyncRequestBase* pRequest )
{
g_pAsyncFileSystem->ReleaseAsyncRequest( pRequest );
pRequest = NULL;
}
//-----------------------------------------------------------------------------
// ::NewAsyncRequestGroup() - Helper function to set up a new file search
// used with a search path..
//-----------------------------------------------------------------------------
inline IAsyncSearchRequest* AsyncFindFiles( const char* pPathID, const char* pSearchSpec )
{
IAsyncSearchRequest* theRequest = g_pAsyncFileSystem->CreateNewSearchRequest(); // Open a new request
theRequest->SetSearchPathAndFileSpec( pPathID, pSearchSpec );
theRequest->SetSubdirectoryScan( false );
return theRequest; // return request object pointer
}
//-----------------------------------------------------------------------------
// ::NewAsyncRequestGroup() - Helper function to set up a new request group
// object
//-----------------------------------------------------------------------------
inline IAsyncGroupRequest* NewAsyncRequestGroup()
{
return g_pAsyncFileSystem->CreateNewAsyncRequestGroup();
}
#endif // IASYNCFILESYSTEM_H