本文整理汇总了C++中CKnownFile::LoadFromFile方法的典型用法代码示例。如果您正苦于以下问题:C++ CKnownFile::LoadFromFile方法的具体用法?C++ CKnownFile::LoadFromFile怎么用?C++ CKnownFile::LoadFromFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CKnownFile
的用法示例。
在下文中一共展示了CKnownFile::LoadFromFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadKnownFiles
bool CKnownFileList::LoadKnownFiles()
{
CString fullpath = thePrefs.GetMuleDirectory(EMULE_CONFIGDIR);
fullpath.Append(KNOWN_MET_FILENAME);
CSafeBufferedFile file;
CFileException fexp;
if (!file.Open(fullpath,CFile::modeRead|CFile::osSequentialScan|CFile::typeBinary|CFile::shareDenyWrite, &fexp)){
if (fexp.m_cause != CFileException::fileNotFound){
CString strError(_T("Failed to load ") KNOWN_MET_FILENAME _T(" file"));
TCHAR szError[MAX_CFEXP_ERRORMSG];
if (fexp.GetErrorMessage(szError, ARRSIZE(szError))){
strError += _T(" - ");
strError += szError;
}
LogError(LOG_STATUSBAR, _T("%s"), strError);
}
return false;
}
setvbuf(file.m_pStream, NULL, _IOFBF, 16384);
CKnownFile* pRecord = NULL;
try {
uint8 header = file.ReadUInt8();
if (header != MET_HEADER && header != MET_HEADER_I64TAGS){
file.Close();
LogError(LOG_STATUSBAR, GetResString(IDS_ERR_SERVERMET_BAD));
return false;
}
AddDebugLogLine(false, _T("Known.met file version is %u (%s support 64bit tags)"), header, (header == MET_HEADER) ? _T("doesn't") : _T("does"));
UINT RecordsNumber = file.ReadUInt32();
for (UINT i = 0; i < RecordsNumber; i++) {
pRecord = new CKnownFile();
if (!pRecord->LoadFromFile(&file)){
TRACE(_T("*** Failed to load entry %u (name=%s hash=%s size=%I64u parthashs=%u expected parthashs=%u) from known.met\n"), i,
pRecord->GetFileName(), md4str(pRecord->GetFileHash()), pRecord->GetFileSize(), pRecord->GetHashCount(), pRecord->GetED2KPartHashCount());
delete pRecord;
pRecord = NULL;
continue;
}
SafeAddKFile(pRecord);
pRecord = NULL;
}
file.Close();
}
catch(CFileException* error){
if (error->m_cause == CFileException::endOfFile)
LogError(LOG_STATUSBAR, GetResString(IDS_ERR_SERVERMET_BAD));
else{
TCHAR buffer[MAX_CFEXP_ERRORMSG];
error->GetErrorMessage(buffer, ARRSIZE(buffer));
LogError(LOG_STATUSBAR, GetResString(IDS_ERR_SERVERMET_UNKNOWN),buffer);
}
error->Delete();
delete pRecord;
return false;
}
return true;
}