12namespace persistence_util {
18 auto dat_file = dir / filename;
29 const uint32_t max_supported_version) {
36 if( totem != magic_number) {
38 "File has unexpected magic number: ${actual_totem}. Expected ${expected_totem}",
39 (
"actual_totem", totem)
40 (
"expected_totem", magic_number));
46 if( version < min_supported_version || version > max_supported_version) {
48 "Unsupported version for file. "
49 "Version is ${version} while code supports version(s) [${min},${max}]",
51 (
"min", min_supported_version)
52 (
"max", max_supported_version));
62 auto dat_file = dir / filename;
70 dat_content.
write(
reinterpret_cast<const char*
>(&magic_number),
sizeof(magic_number) );
71 dat_content.
write(
reinterpret_cast<const char*
>(¤t_version),
sizeof(current_version) );
static constexpr const char * truncate_rw_mode
static constexpr const char * create_or_update_rw_mode
cfile_datastream create_datastream()
void open(const char *mode)
void set_file_path(fc::path file_path)
void write(const char *d, size_t n)
wraps boost::filesystem::path to provide platform independent path manipulation.
#define FC_THROW_EXCEPTION(EXCEPTION, FORMAT,...)
cfile open_cfile_for_write(const fc::path &dir, const std::string &filename)
void write_persistence_header(cfile &dat_content, const uint32_t magic_number, const uint32_t current_version)
uint32_t read_persistence_header(cfile &dat_content, const uint32_t magic_number, const uint32_t min_supported_version, const uint32_t max_supported_version)
cfile open_cfile_for_read(const fc::path &dir, const std::string &filename)
void unpack(Stream &s, std::deque< T > &value)
bool exists(const path &p)
void create_directories(const path &p)
bool is_directory(const path &p)