| 525 | // eSerializer is thrown if reading or writing fails |
| 526 | |
| 527 | void cTWUtil::WriteConfigText(const TCHAR* filename, |
| 528 | const TSTRING configText, |
| 529 | bool bEncrypt, |
| 530 | const cElGamalSigPrivateKey* pPrivateKey) |
| 531 | { |
| 532 | cSerializableNString nstring; |
| 533 | |
| 534 | nstring.mString = CONFIG_FILE_MAGIC_8BYTE; |
| 535 | |
| 536 | std::string ns; |
| 537 | cStringUtil::Convert(ns, configText); |
| 538 | nstring.mString += ns; |
| 539 | |
| 540 | cFileHeader fileHeader; |
| 541 | fileHeader.SetID(cConfigFile::GetFileHeaderID()); |
| 542 | |
| 543 | fileHeader.SetVersion(CURRENT_FIXED_VERSION); |
| 544 | |
| 545 | if (bEncrypt) |
| 546 | { |
| 547 | ASSERT(pPrivateKey != 0); |
| 548 | cElGamalSigPublicKey publicKey(*pPrivateKey); |
| 549 | fileHeader.GetBaggage().MapArchive(0, publicKey.GetWriteLen()); |
| 550 | publicKey.Write(fileHeader.GetBaggage().GetMap()); |
| 551 | } |
| 552 | |
| 553 | WriteObject(filename, NULL, nstring, fileHeader, bEncrypt, pPrivateKey); |
| 554 | |
| 555 | iUserNotify::GetInstance()->Notify(iUserNotify::V_NORMAL, |
| 556 | _T("%s%s\n"), |
| 557 | TSS_GetString(cTW, tw::STR_WRITE_CONFIG_FILE).c_str(), |
| 558 | cDisplayEncoder::EncodeInline(filename).c_str()); |
| 559 | } |
| 560 | |
| 561 | |
| 562 | /////////////////////////////////////////////////////////////////////////////// |
nothing calls this directly
no test coverage detected