| 511 | |
| 512 | |
| 513 | void 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 | } |