void GDocApp<OptionsFmt>::SetCurFile(char *f) { if (f != d->CurFile) { d->CurFile.Reset(NewStr(f)); } GAutoString Display; if (SerializeEntry(&Display, &d->CurFile, NULL)) { char s[MAX_PATH + 100]; if (Display) { sprintf_s(s, sizeof(s), "%s [%s%s]", d->AppName, Display.Get(), d->Dirty ? " changed" : ""); } else if (d->Dirty) { sprintf_s(s, sizeof(s), "%s [changed]", d->AppName); } else { strcpy_s(s, sizeof(s), d->AppName); } Name(s); } }
void VolumeHeader::Serialize (const BufferPtr &header) const { if (header.Size() != EncryptedHeaderDataSize) throw ParameterIncorrect (SRC_POS); header.Zero(); header[0] = 'V'; header[1] = 'E'; header[2] = 'R'; header[3] = 'A'; size_t offset = 4; header.GetRange (DataAreaKeyOffset, DataAreaKey.Size()).CopyFrom (DataAreaKey); uint16 headerVersion = CurrentHeaderVersion; SerializeEntry (headerVersion, header, offset); SerializeEntry (RequiredMinProgramVersion, header, offset); SerializeEntry (Crc32::ProcessBuffer (header.GetRange (DataAreaKeyOffset, DataKeyAreaMaxSize)), header, offset); uint64 reserved64 = 0; SerializeEntry (reserved64, header, offset); SerializeEntry (reserved64, header, offset); SerializeEntry (HiddenVolumeDataSize, header, offset); SerializeEntry (VolumeDataSize, header, offset); SerializeEntry (EncryptedAreaStart, header, offset); SerializeEntry (EncryptedAreaLength, header, offset); SerializeEntry (Flags, header, offset); if (SectorSize < TC_MIN_VOLUME_SECTOR_SIZE || SectorSize > TC_MAX_VOLUME_SECTOR_SIZE || SectorSize % ENCRYPTION_DATA_UNIT_SIZE != 0) { throw ParameterIncorrect (SRC_POS); } SerializeEntry (SectorSize, header, offset); offset = TC_HEADER_OFFSET_HEADER_CRC - TC_HEADER_OFFSET_MAGIC; SerializeEntry (Crc32::ProcessBuffer (header.GetRange (0, TC_HEADER_OFFSET_HEADER_CRC - TC_HEADER_OFFSET_MAGIC)), header, offset); }