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

Method WriteTag

src/SafeFile.cpp:513–570  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

511
512
513void CFileDataIO::WriteTag(const CTag& tag)
514{
515 try
516 {
517 WriteUInt8(tag.GetType());
518
519 if (!tag.GetName().IsEmpty()) {
520 WriteString(tag.GetName(),utf8strNone);
521 } else {
522 WriteUInt16(1);
523 WriteUInt8(tag.GetNameID());
524 }
525
526 switch (tag.GetType())
527 {
528 case TAGTYPE_HASH16:
529 // Do NOT use this to transfer any tags for at least half a year!!
530 WriteHash(CMD4Hash(tag.GetHash()));
531 break;
532 case TAGTYPE_STRING:
533 WriteString(tag.GetStr(), utf8strRaw); // Always UTF8
534 break;
535 case TAGTYPE_UINT64:
536 WriteUInt64(tag.GetInt());
537 break;
538 case TAGTYPE_UINT32:
539 WriteUInt32(tag.GetInt());
540 break;
541 case TAGTYPE_FLOAT32:
542 WriteFloat(tag.GetFloat());
543 break;
544 case TAGTYPE_BSOB:
545 WriteBsob(tag.GetBsob(), tag.GetBsobSize());
546 break;
547 case TAGTYPE_UINT16:
548 WriteUInt16(tag.GetInt());
549 break;
550 case TAGTYPE_UINT8:
551 WriteUInt8(tag.GetInt());
552 break;
553 case TAGTYPE_BLOB:
554 // NOTE: This will break backward compatibility with met files for eMule versions prior to 0.44a
555 // and any aMule prior to SVN 26/02/2005
556 WriteUInt32(tag.GetBlobSize());
557 Write(tag.GetBlob(), tag.GetBlobSize());
558 break;
559 default:
560 //TODO: Support more tag types
561 // With the if above, this should NEVER happen.
562 AddLogLineNS(CFormat("CFileDataIO::WriteTag: Unknown tag: type=0x%02X") % tag.GetType());
563 wxFAIL;
564 break;
565 }
566 } catch (...) {
567 AddLogLineNS("Exception in CDataIO:WriteTag");
568 throw;
569 }
570}

Callers 2

WriteTagToFileMethod · 0.45
check_single_kad_tagFunction · 0.45

Calls 13

CFormatClass · 0.85
GetNameMethod · 0.80
GetNameIDMethod · 0.80
GetFloatMethod · 0.80
GetBsobMethod · 0.80
GetBsobSizeMethod · 0.80
GetBlobSizeMethod · 0.80
GetBlobMethod · 0.80
CMD4HashClass · 0.70
GetTypeMethod · 0.45
IsEmptyMethod · 0.45
GetHashMethod · 0.45

Tested by 1

check_single_kad_tagFunction · 0.36