BVB Source Codes

CRYENGINE Show ReadOnlyChunkFile.h Source code

Return Download CRYENGINE: download ReadOnlyChunkFile.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. // -------------------------------------------------------------------------
  4. //  File name:   ReadOnlyChunkFile.h
  5. //  Created:     2004/11/15 by Timur
  6. //
  7. ////////////////////////////////////////////////////////////////////////////
  8.  
  9. #ifndef __ReadOnlyChunkFile_h__
  10. #define __ReadOnlyChunkFile_h__
  11.  
  12. #include <Cry3DEngine/CGF/CryHeaders.h>
  13. #include <CryCore/smartptr.h>
  14. #include <Cry3DEngine/CGF/IChunkFile.h>
  15.  
  16. ////////////////////////////////////////////////////////////////////////
  17. // Chunk file reader.
  18. // Accesses a chunked file structure through file mapping object.
  19. // Opens a chunk file and checks for its validity.
  20. // If it's invalid, closes it as if there was no open operation.
  21. // Error handling is performed through the return value of Read: it must
  22. // be true for successfully open files
  23. ////////////////////////////////////////////////////////////////////////
  24.  
  25. class CReadOnlyChunkFile : public IChunkFile
  26. {
  27. public:
  28.         //////////////////////////////////////////////////////////////////////////
  29.         CReadOnlyChunkFile(bool bCopyFileData, bool bNoWarningMode = false);
  30.         virtual ~CReadOnlyChunkFile();
  31.  
  32.         // interface IChunkFile --------------------------------------------------
  33.  
  34.         virtual void             Release()          { delete this; }
  35.  
  36.         virtual bool             IsReadOnly() const { return true; }
  37.         virtual bool             IsLoaded() const   { return m_bLoaded; }
  38.  
  39.         virtual bool             Read(const char* filename);
  40.         virtual bool             ReadFromMemory(const void* pData, int nDataSize);
  41.  
  42.         virtual bool             Write(const char* filename)                                                                                     { return false; }
  43.         virtual bool             WriteToMemoryBuffer(void** pData, int* nSize)                                                                   { return false; }
  44.         virtual void             ReleaseMemoryBuffer()                                                                                           {}
  45.  
  46.         virtual int              AddChunk(ChunkTypes chunkType, int chunkVersion, EEndianness eEndianness, const void* chunkData, int chunkSize) { return -1; }
  47.         virtual void             DeleteChunkById(int nChunkId)                                                                                   {}
  48.         virtual void             DeleteChunksByType(ChunkTypes nChunkType)                                                                       {}
  49.  
  50.         virtual ChunkDesc*       FindChunkByType(ChunkTypes nChunkType);
  51.         virtual ChunkDesc*       FindChunkById(int nChunkId);
  52.  
  53.         virtual int              NumChunks() const;
  54.  
  55.         virtual ChunkDesc*       GetChunk(int nIndex);
  56.         virtual const ChunkDesc* GetChunk(int nIndex) const;
  57.  
  58.         virtual const char*      GetLastError() const { return m_LastError; }
  59.  
  60.         // -----------------------------------------------------------------------
  61.  
  62.         virtual void GetMemoryUsage(ICrySizer* pSizer) const
  63.         {
  64.                 pSizer->AddObject(this, sizeof(*this));
  65.                 pSizer->AddObject(m_LastError);
  66.                 pSizer->AddObject(m_chunks);
  67.         }
  68. private:
  69.         bool ReadChunkTableFromBuffer();
  70.         void FreeBuffer();
  71.         void CloseFile();
  72.  
  73. private:
  74.         // this variable contains the last error occurred in this class
  75.         string                 m_LastError;
  76.  
  77.         std::vector<ChunkDesc> m_chunks;
  78.  
  79.         char*                  m_pFileBuffer;
  80.         int                    m_nBufferSize;
  81.         bool                   m_bOwnFileBuffer;
  82.         bool                   m_bNoWarningMode;
  83.         bool                   m_bLoaded;
  84.         bool                   m_bCopyFileData;
  85.  
  86.         FILE*                  m_hFile;
  87. };
  88.  
  89. TYPEDEF_AUTOPTR(CReadOnlyChunkFile);
  90.  
  91. #endif
  92.  
downloadReadOnlyChunkFile.h Source code - Download CRYENGINE Source code
Related Source Codes/Software:
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top