00001 /* RageFileDriverMem: Simple memory-based "filesystem". */ 00002 00003 #ifndef RAGE_FILE_DRIVER_MEMORY_H 00004 #define RAGE_FILE_DRIVER_MEMORY_H 00005 00006 #include "RageFileDriver.h" 00007 #include "RageThreads.h" 00008 00009 struct RageFileObjMemFile; 00010 class RageFileObjMem: public RageFileObj 00011 { 00012 public: 00013 RageFileObjMem( RageFileObjMemFile *pFile = NULL ); 00014 RageFileObjMem( const RageFileObjMem &cpy ); 00015 ~RageFileObjMem(); 00016 00017 int ReadInternal( void *buffer, size_t bytes ); 00018 int WriteInternal( const void *buffer, size_t bytes ); 00019 int SeekInternal( int offset ); 00020 int GetFileSize() const; 00021 RageFileBasic *Copy() const; 00022 00023 /* Retrieve the contents of this file. */ 00024 const CString &GetString() const; 00025 void PutString( const CString &sBuf ); 00026 00027 private: 00028 RageFileObjMemFile *m_pFile; 00029 int m_iFilePos; 00030 }; 00031 00032 class RageFileDriverMem: public RageFileDriver 00033 { 00034 public: 00035 RageFileDriverMem(); 00036 ~RageFileDriverMem(); 00037 00038 RageFileBasic *Open( const CString &sPath, int mode, int &err ); 00039 void FlushDirCache( const CString &sPath ) { } 00040 00041 bool Remove( const CString &sPath ); 00042 00043 private: 00044 RageMutex m_Mutex; 00045 vector<RageFileObjMemFile *> m_Files; 00046 }; 00047 00048 #endif 00049 00050 /* 00051 * (c) 2004 Glenn Maynard 00052 * All rights reserved. 00053 * 00054 * Permission is hereby granted, free of charge, to any person obtaining a 00055 * copy of this software and associated documentation files (the 00056 * "Software"), to deal in the Software without restriction, including 00057 * without limitation the rights to use, copy, modify, merge, publish, 00058 * distribute, and/or sell copies of the Software, and to permit persons to 00059 * whom the Software is furnished to do so, provided that the above 00060 * copyright notice(s) and this permission notice appear in all copies of 00061 * the Software and that both the above copyright notice(s) and this 00062 * permission notice appear in supporting documentation. 00063 * 00064 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00065 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00066 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF 00067 * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS 00068 * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT 00069 * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 00070 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 00071 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 00072 * PERFORMANCE OF THIS SOFTWARE. 00073 */