| 218 | |
| 219 | |
| 220 | bool CHashingTask::CreateNextPartHash(CFileAutoClose& file, uint16 part, CKnownFile* owner, EHashes toHash) |
| 221 | { |
| 222 | wxCHECK_MSG(!file.Eof(), false, "Unexpected EOF in CreateNextPartHash"); |
| 223 | |
| 224 | const uint64 offset = part * PARTSIZE; |
| 225 | // We'll read at most PARTSIZE bytes per cycle |
| 226 | const uint64 partLength = owner->GetPartSize(part); |
| 227 | |
| 228 | CMD4Hash hash; |
| 229 | CMD4Hash* md4Hash = ((toHash & EH_MD4) ? &hash : NULL); |
| 230 | CAICHHashTree* aichHash = NULL; |
| 231 | |
| 232 | // Setup for AICH hashing |
| 233 | if (toHash & EH_AICH) { |
| 234 | aichHash = owner->GetAICHHashset()->m_pHashTree.FindHash(offset, partLength); |
| 235 | } |
| 236 | |
| 237 | owner->CreateHashFromFile(file, offset, partLength, md4Hash, aichHash); |
| 238 | |
| 239 | if (toHash & EH_MD4) { |
| 240 | // Store the md4 hash |
| 241 | owner->m_hashlist.push_back(hash); |
| 242 | |
| 243 | // This is because of the ed2k implementation for parts. A 2 * PARTSIZE |
| 244 | // file i.e. will have 3 parts (see CKnownFile::SetFileSize for comments). |
| 245 | // So we have to create the hash for the 0-size data, which will be the default |
| 246 | // md4 hash for null data: 31D6CFE0D16AE931B73C59D7E0C089C0 |
| 247 | if ((partLength == PARTSIZE) && file.Eof()) { |
| 248 | owner->m_hashlist.push_back(CMD4Hash(g_emptyMD4Hash)); |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | return true; |
| 253 | } |
| 254 | |
| 255 | |
| 256 | void CHashingTask::OnLastTask() |
nothing calls this directly
no test coverage detected