本文整理汇总了C++中MD5::result方法的典型用法代码示例。如果您正苦于以下问题:C++ MD5::result方法的具体用法?C++ MD5::result怎么用?C++ MD5::result使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MD5
的用法示例。
在下文中一共展示了MD5::result方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: append_file
bool append_file(const char* path,const char* file_name,MPQPackage* pPkg,FILE* fp_log)
{
if ( !path || !file_name || !pPkg)
{
return false;
}
string fullPathKey = stringTrim(path,"\n");
string filePathKey = stringTrim(file_name,"\n");
if ( filePathKey.empty() )
{
return false;
}
if ( fullPathKey.empty() )
{
fullPathKey = filePathKey;
}
else
{
fullPathKey.append("/");
fullPathKey.append(filePathKey);
}
FILE* fp = fopen(fullPathKey.c_str(),"rb");
if ( !fp )
{
if ( fp_log )
{
fprintf(fp_log,"can't open file %s\n",fullPathKey.c_str());
}
return false;
}
// md5 check code
MD5 m;
m.update(fp);
fseek(fp,0,SEEK_END);
unsigned int file_size = ftell(fp);
m.update(&file_size,sizeof(unsigned int));
unsigned char* pData = new unsigned char[file_size];
if ( !pData )
{
if ( fp_log )
{
fprintf(fp_log,"can't assign memory for file %s\n",fullPathKey.c_str());
}
fclose(fp);
return false;
}
fseek(fp,0,SEEK_SET);
fread(pData,1,file_size,fp);
fclose(fp);
bool bCompress = true;
if ((std::string::npos != fullPathKey.find(".jpg")) ||
(std::string::npos != fullPathKey.find(".png")) ||
(std::string::npos != fullPathKey.find(".pvr")))
{
bCompress = false;
}
MPQHashNode* pNode = pPkg->get_hash_node_new(filePathKey.c_str());
if ( !pNode )
{
// no space
if ( fp_log )
{
fprintf(fp_log,"no hash node left for file %s\n",filePathKey.c_str());
}
delete pData;
return false;
}
unsigned int blockIndex = pPkg->append_data(pData,file_size,bCompress);
if ( blockIndex == MPQ_INVALID )
{
pPkg->reset_hash_node(pNode);
delete pData;
if ( fp_log )
{
fprintf(fp_log,"append data failed for file %s\n",filePathKey.c_str());
}
return false;
}
pNode->block_index = blockIndex;
MPQBlock* pBlock = pPkg->get_block(pNode);
memcpy(pBlock->md5_code,m.result(),MPQ_MD5_CODE_LEN);
pBlock->name = filePathKey;
delete pData;
if ( fp_log )
{
fprintf(fp_log,"added file %s \n",filePathKey.c_str());
}
//.........这里部分代码省略.........