// (c) 2002 Microsoft Corporation // [jorgeba] Jorge Peraza #include "StdAfx.h" #include "fastfilehash.h" CFastFileHash::CFastFileHash(void):m_hFile(0),m_iFileSize(0) { } CFastFileHash::~CFastFileHash(void) { } __int32* CFastFileHash::getHash(TCHAR *sFileName) { __int32* iHash = NULL; if(sFileName==NULL) { return NULL; } if(!openFile(sFileName)) { return NULL; } iHash = calcHash(); CloseHandle(m_hFile); return iHash; } int CFastFileHash::openFile(TCHAR *sFileName) { m_hFile = CreateFile(sFileName,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_ALWAYS,0,NULL); if(m_hFile==INVALID_HANDLE_VALUE) { return FALSE; } else { return TRUE; } } __int32* CFastFileHash::calcHash() { int iFlag = 0; int iNdx = 0; int iNumOfParts = 0; char bFilePart[PART_SIZE]; __int32* piRes = NULL; //Clear common vars m_iFileSize = 0; //Create the memory for the hash piRes = new __int32[5]; if(piRes==NULL) { return NULL; } memset(piRes,0,sizeof(__int32)*5); //First, get the size of the file m_iFileSize = GetFileSize(m_hFile,NULL); iNumOfParts = m_iFileSize / PART_SIZE; //Fill the parts buffer for(iNdx=0;iNdx