MCPcopy Create free account
hub / github.com/amule-project/amule / LoadHashsetFromFile

Method LoadHashsetFromFile

src/KnownFile.cpp:557–599  ·  view source on GitHub ↗

needed for memfiles. its probably better to switch everything to CFile...

Source from the content-addressed store, hash-verified

555
556// needed for memfiles. its probably better to switch everything to CFile...
557bool CKnownFile::LoadHashsetFromFile(const CFileDataIO* file, bool checkhash)
558{
559 CMD4Hash checkid = file->ReadHash();
560
561 uint16 parts = file->ReadUInt16();
562 m_hashlist.clear();
563 for (uint16 i = 0; i < parts; ++i){
564 CMD4Hash cur_hash = file->ReadHash();
565 m_hashlist.push_back(cur_hash);
566 }
567
568 // SLUGFILLER: SafeHash - always check for valid m_hashlist
569 if (!checkhash){
570 m_abyFileHash = checkid;
571 if (parts <= 1) { // nothing to check
572 return true;
573 }
574 } else {
575 if ( m_abyFileHash != checkid ) {
576 return false; // wrong file?
577 } else {
578 if (parts != GetED2KPartHashCount()) {
579 return false;
580 }
581 }
582 }
583 // SLUGFILLER: SafeHash
584
585 // trust noone ;-)
586 // lol, useless comment but made me lmao
587 // wtf you guys are weird.
588
589 if (!m_hashlist.empty()) {
590 CreateHashFromHashlist(m_hashlist, &checkid);
591 }
592
593 if ( m_abyFileHash == checkid ) {
594 return true;
595 } else {
596 m_hashlist.clear();
597 return false;
598 }
599}
600
601
602bool CKnownFile::LoadTagsFromFile(const CFileDataIO* file)

Callers 1

ProcessHashSetMethod · 0.80

Calls 4

ReadUInt16Method · 0.80
ReadHashMethod · 0.45
clearMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected