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

Method WriteToFile

src/KnownFile.cpp:745–858  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

743
744
745bool CKnownFile::WriteToFile(CFileDataIO* file)
746{
747 wxCHECK(!IsPartFile(), false);
748
749 // date
750 file->WriteUInt32((uint32)m_lastDateChanged);
751 // hashset
752 file->WriteHash(m_abyFileHash);
753
754 uint16 parts = m_hashlist.size();
755 file->WriteUInt16(parts);
756
757 for (int i = 0; i < parts; ++i)
758 file->WriteHash(m_hashlist[i]);
759
760 //tags
761 const int iFixedTags = 9; // +1 for FT_LASTSEEN
762 uint32 tagcount = iFixedTags;
763 if (HasProperAICHHashSet()) {
764 tagcount++;
765 }
766 // Float meta tags are currently not written. All older eMule versions < 0.28a have
767 // a bug in the meta tag reading+writing code. To achieve maximum backward
768 // compatibility for met files with older eMule versions we just don't write float
769 // tags. This is OK, because we (eMule) do not use float tags. The only float tags
770 // we may have to handle is the '# Sent' tag from the Hybrid, which is pretty
771 // useless but may be received from us via the servers.
772 //
773 // The code for writing the float tags SHOULD BE ENABLED in SOME MONTHS (after most
774 // people are using the newer eMule versions which do not write broken float tags).
775 for (size_t j = 0; j < m_taglist.size(); ++j){
776 if (m_taglist[j].IsInt() || m_taglist[j].IsStr()) {
777 ++tagcount;
778 }
779 }
780
781 if (m_lastPublishTimeKadSrc) {
782 ++tagcount;
783 }
784
785 if (m_lastPublishTimeKadNotes){
786 ++tagcount;
787 }
788
789 // standard tags
790
791 file->WriteUInt32(tagcount);
792
793 // We still save the unicoded filename, for backwards
794 // compatibility with pre-2.2 and other clients.
795 CTagString nametag_unicode(FT_FILENAME, GetFileName().GetRaw());
796 // We write it with BOM to keep eMule compatibility
797 nametag_unicode.WriteTagToFile(file,utf8strOptBOM);
798
799 // The non-unicoded filename is written in an 'universial'
800 // format, which allows us to identify files, even if the
801 // system locale changes.
802 CTagString nametag(FT_FILENAME, CPath::ToUniv(GetFileName()));

Callers

nothing calls this directly

Calls 12

WriteUInt32Method · 0.80
WriteUInt16Method · 0.80
IsStrMethod · 0.80
GetRawMethod · 0.80
WriteTagToFileMethod · 0.80
GetAllTimeTransferredMethod · 0.80
GetAllTimeRequestsMethod · 0.80
GetAllTimeAcceptsMethod · 0.80
WriteHashMethod · 0.45
sizeMethod · 0.45
IsIntMethod · 0.45
GetStringMethod · 0.45

Tested by

no test coverage detected