diff options
Diffstat (limited to 'contrib/epee/src/portable_storage.cpp')
-rw-r--r-- | contrib/epee/src/portable_storage.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/contrib/epee/src/portable_storage.cpp b/contrib/epee/src/portable_storage.cpp new file mode 100644 index 000000000..4534deff3 --- /dev/null +++ b/contrib/epee/src/portable_storage.cpp @@ -0,0 +1,29 @@ + +#include "byte_slice.h" +#include "byte_stream.h" +#include "misc_log_ex.h" +#include "span.h" +#include "storages/portable_storage.h" +#include "storages/portable_storage_to_bin.h" + +namespace epee +{ +namespace serialization +{ + bool portable_storage::store_to_binary(byte_slice& target, const std::size_t initial_buffer_size) + { + TRY_ENTRY(); + byte_stream ss; + ss.reserve(initial_buffer_size); + storage_block_header sbh{}; + sbh.m_signature_a = SWAP32LE(PORTABLE_STORAGE_SIGNATUREA); + sbh.m_signature_b = SWAP32LE(PORTABLE_STORAGE_SIGNATUREB); + sbh.m_ver = PORTABLE_STORAGE_FORMAT_VER; + ss.write(epee::as_byte_span(sbh)); + pack_entry_to_buff(ss, m_root); + target = epee::byte_slice{std::move(ss)}; + return true; + CATCH_ENTRY("portable_storage::store_to_binary", false) + } +} +} |