bool core::archive::image_cache::unserialize_block(core::tools::binary_stream& _stream, images_map_t& _images) const { while (_stream.available()) { core::tools::tlvpack block; if (!block.unserialize(_stream)) return false; for (auto item = block.get_first(); item; item = block.get_next()) { image_data img; auto stream = item->get_value<core::tools::binary_stream>(); if (!img.unserialize(stream)) return false; const auto id = img.get_msgid(); _images.emplace(id, std::move(img)); } } return true; }
bool storage::write_data_block(core::tools::binary_stream& _data, int64_t& _offset) { if (!active_file_stream_) { assert(!"file stream not opened"); return false; } _offset = active_file_stream_->tellp(); uint32_t data_size = _data.available(); active_file_stream_->write((const char*) &data_size, sizeof(data_size)); active_file_stream_->write((const char*) &data_size, sizeof(data_size)); if (data_size) active_file_stream_->write((const char*) _data.read(data_size), data_size); active_file_stream_->write((const char*) &data_size, sizeof(data_size)); active_file_stream_->write((const char*) &data_size, sizeof(data_size)); return true; }