本文整理汇总了C++中CKnownFile::GetLastChangeDatetime方法的典型用法代码示例。如果您正苦于以下问题:C++ CKnownFile::GetLastChangeDatetime方法的具体用法?C++ CKnownFile::GetLastChangeDatetime怎么用?C++ CKnownFile::GetLastChangeDatetime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CKnownFile
的用法示例。
在下文中一共展示了CKnownFile::GetLastChangeDatetime方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Append
bool CKnownFileList::Append(CKnownFile *Record, bool afterHashing)
{
if (Record->GetFileSize() > 0) {
const CMD4Hash& tkey = Record->GetFileHash();
CKnownFileMap::iterator it = m_knownFileMap.find(tkey);
if (it == m_knownFileMap.end()) {
m_knownFileMap[tkey] = Record;
return true;
} else {
CKnownFile *existing = it->second;
if (KnownFileMatches(Record, existing->GetFileName(), existing->GetLastChangeDatetime(), existing->GetFileSize())) {
// The file is already on the list, ignore it.
AddDebugLogLineN(logKnownFiles, CFormat(wxT("%s is already on the list")) % Record->GetFileName().GetPrintable());
return false;
} else if (IsOnDuplicates(Record->GetFileName(), Record->GetLastChangeDatetime(), Record->GetFileSize())) {
// The file is on the duplicates list, ignore it.
// Should not happen, at least not after hashing. Or why did it get hashed in the first place then?
AddDebugLogLineN(logKnownFiles, CFormat(wxT("%s is on the duplicates list")) % Record->GetFileName().GetPrintable());
return false;
} else {
if (afterHashing && existing->GetFileSize() == Record->GetFileSize()) {
// We just hashed a "new" shared file and find it's already known under a different name or date.
// Guess what - it was probably renamed or touched.
// So copy over all properties from the existing known file and just keep name/date.
time_t newDate = Record->GetLastChangeDatetime();
CPath newName = Record->GetFileName();
CMemFile f;
existing->WriteToFile(&f);
f.Reset();
Record->LoadFromFile(&f);
Record->SetLastChangeDatetime(newDate);
Record->SetFileName(newName);
}
// The file is a duplicated hash. Add THE OLD ONE to the duplicates list.
// (This is used when reading the known file list where the duplicates are stored in front.)
m_duplicateFileList.push_back(existing);
if (theApp->sharedfiles) {
// Removing the old kad keywords created with the old filename
theApp->sharedfiles->RemoveKeywords(existing);
}
m_knownFileMap[tkey] = Record;
return true;
}
}
} else {
AddDebugLogLineN(logGeneral,
CFormat(wxT("%s is 0-size, not added")) %
Record->GetFileName());
return false;
}
}