From 2a72c0b38b8c2610001f24340097ad3a1b052263 Mon Sep 17 00:00:00 2001 From: oy Date: Thu, 31 Mar 2011 15:13:49 +0200 Subject: added a mechanism to check for a valid standard map. Closes #132 --- src/engine/shared/datafile.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/engine/shared/datafile.cpp') diff --git a/src/engine/shared/datafile.cpp b/src/engine/shared/datafile.cpp index 74583ab8..74936ea0 100644 --- a/src/engine/shared/datafile.cpp +++ b/src/engine/shared/datafile.cpp @@ -222,6 +222,32 @@ bool CDataFileReader::Open(class IStorage *pStorage, const char *pFilename, int return true; } +bool CDataFileReader::GetCrcSize(class IStorage *pStorage, const char *pFilename, int StorageType, unsigned *pCrc, unsigned *pSize) +{ + IOHANDLE File = pStorage->OpenFile(pFilename, IOFLAG_READ, StorageType); + if(!File) + return false; + + // get crc and size + unsigned Crc = 0; + unsigned Size = 0; + unsigned char aBuffer[64*1024]; + while(1) + { + unsigned Bytes = io_read(File, aBuffer, sizeof(aBuffer)); + if(Bytes <= 0) + break; + Crc = crc32(Crc, aBuffer, Bytes); // ignore_convention + Size += Bytes; + } + + io_close(File); + + *pCrc = Crc; + *pSize = Size; + return true; +} + int CDataFileReader::NumData() { if(!m_pDataFile) { return 0; } -- cgit 1.4.1