diff options
| author | oy <Tom_Adams@web.de> | 2011-03-31 15:13:49 +0200 |
|---|---|---|
| committer | oy <Tom_Adams@web.de> | 2011-03-31 15:13:49 +0200 |
| commit | 2a72c0b38b8c2610001f24340097ad3a1b052263 (patch) | |
| tree | aee816df77e1f1ac772d5a797b822d2ffc0c09b5 /src/engine/shared/datafile.cpp | |
| parent | 59d56cd332ecc86008c27326631566a4d2d94ecb (diff) | |
| download | zcatch-2a72c0b38b8c2610001f24340097ad3a1b052263.tar.gz zcatch-2a72c0b38b8c2610001f24340097ad3a1b052263.zip | |
added a mechanism to check for a valid standard map. Closes #132
Diffstat (limited to 'src/engine/shared/datafile.cpp')
| -rw-r--r-- | src/engine/shared/datafile.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
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; } |