#include "StdAfx.h"
|
#include "MBFileMD5Mgr.h"
|
|
|
CMBFileMD5Info::CMBFileMD5Info()
|
{
|
|
|
}
|
|
CMBFileMD5Info::~CMBFileMD5Info()
|
{
|
|
|
}
|
|
/////////////////////////////////////////////////
|
|
|
CMBFileMD5Mgr::CMBFileMD5Mgr(void)
|
{
|
RemoveAllFileMD5Info();
|
}
|
|
|
CMBFileMD5Mgr::~CMBFileMD5Mgr(void)
|
{
|
RemoveAllFileMD5Info();
|
}
|
|
bool CMBFileMD5Mgr::AddFileMD5Info(CMBFileMD5Info *pFileMD5Info)
|
{
|
CSingleLock lock( &m_cs, true );
|
|
if( NULL == pFileMD5Info || pFileMD5Info->m_strKey.IsEmpty() )
|
return false;
|
|
CMBFileMD5InfoMap::iterator it;
|
CString strKey;
|
|
strKey = pFileMD5Info->m_strKey;
|
it = m_mapFileMD5Info.find(strKey);
|
|
// Èç¹ûÕҵõ½ ·µ»Ø
|
if( it != m_mapFileMD5Info.end() )
|
return false;
|
m_mapFileMD5Info[strKey] = pFileMD5Info;
|
return true;
|
}
|
|
CMBFileMD5Info* CMBFileMD5Mgr::GetFileMD5Info( CString strKey )
|
{
|
CSingleLock lock( &m_cs, true );
|
|
if( strKey.IsEmpty() )
|
{
|
return NULL;
|
}
|
|
CMBFileMD5InfoMap::iterator it;
|
CMBFileMD5Info *pFileMD5Info = NULL;
|
|
it = m_mapFileMD5Info.find(strKey);
|
|
if( it!= m_mapFileMD5Info.end() )
|
pFileMD5Info = it->second;
|
|
return pFileMD5Info;
|
}
|
|
// ÒÆ³ý
|
bool CMBFileMD5Mgr::RemoveMD5Info( CString strKey )
|
{
|
CSingleLock lock( &m_cs, true );
|
|
if( strKey.IsEmpty() )
|
return false;
|
|
CMBFileMD5InfoMap::iterator it;
|
CMBFileMD5Info *pFileMD5Info = NULL;
|
|
it = m_mapFileMD5Info.find(strKey);
|
|
if( it!= m_mapFileMD5Info.end() ){
|
pFileMD5Info = it->second;
|
m_mapFileMD5Info.erase(it);
|
delete pFileMD5Info;
|
pFileMD5Info = NULL;
|
}
|
return true;
|
}
|
|
bool CMBFileMD5Mgr::RemoveAllFileMD5Info()
|
{
|
CMBFileMD5InfoMap::iterator it;
|
CMBFileMD5Info *pFileMD5Info = NULL;
|
|
for( it = m_mapFileMD5Info.begin();it != m_mapFileMD5Info.end();it++ )
|
{
|
pFileMD5Info = it->second;
|
delete pFileMD5Info;
|
pFileMD5Info = NULL;
|
}
|
m_mapFileMD5Info.clear();
|
return true;
|
}
|
|
CString CMBFileMD5Mgr::GetKey( CString strFullPathFileName )
|
{
|
return CStrFileUtils::GetMD5(strFullPathFileName);
|
}
|