diff options
Diffstat (limited to '')
-rw-r--r-- | contrib/epee/src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | contrib/epee/src/portable_storage.cpp | 29 |
2 files changed, 30 insertions, 1 deletions
diff --git a/contrib/epee/src/CMakeLists.txt b/contrib/epee/src/CMakeLists.txt index 8adf69162..5e101a86a 100644 --- a/contrib/epee/src/CMakeLists.txt +++ b/contrib/epee/src/CMakeLists.txt @@ -29,7 +29,7 @@ add_library(epee STATIC byte_slice.cpp byte_stream.cpp hex.cpp abstract_http_client.cpp http_auth.cpp mlog.cpp net_helper.cpp net_utils_base.cpp string_tools.cpp wipeable_string.cpp levin_base.cpp memwipe.c connection_basic.cpp network_throttle.cpp network_throttle-detail.cpp mlocker.cpp buffer.cpp net_ssl.cpp - int-util.cpp) + int-util.cpp portable_storage.cpp) if (USE_READLINE AND (GNU_READLINE_FOUND OR (DEPENDS AND NOT MINGW))) add_library(epee_readline STATIC readline_buffer.cpp) 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) + } +} +} |