34 #include <boost/archive/binary_iarchive.hpp>
35 #include <boost/archive/portable_binary_oarchive.hpp>
36 #include <boost/archive/portable_binary_iarchive.hpp>
37 #include <boost/filesystem/operations.hpp>
42 template<
class t_
object>
48 HANDLE data_file_handle = ::CreateFile(file_path.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
49 if (INVALID_HANDLE_VALUE == data_file_handle)
52 int data_file_descriptor = _open_osfhandle((intptr_t)data_file_handle, 0);
53 if (-1 == data_file_descriptor)
55 ::CloseHandle(data_file_handle);
59 const std::unique_ptr<FILE, tools::close_file> data_file_file{_fdopen(data_file_descriptor,
"wb")};
60 if (
nullptr == data_file_file)
63 _close(data_file_descriptor);
68 std::ofstream data_file(data_file_file.get());
75 std::ofstream data_file;
76 data_file.open(file_path , std::ios_base::binary | std::ios_base::out| std::ios::trunc);
81 boost::archive::portable_binary_oarchive
a(data_file);
89 ::FlushFileBuffers(data_file_handle);
93 CATCH_ENTRY_L0(
"serialize_obj_to_file",
false);
96 template<
class t_
object>
101 std::ifstream data_file;
102 data_file.open( file_path, std::ios_base::binary | std::ios_base::in);
108 boost::archive::portable_binary_iarchive
a(data_file);
114 boost::filesystem::copy_file(file_path, file_path +
".unportable", boost::filesystem::copy_option::overwrite_if_exists);
116 data_file.open( file_path, std::ios_base::binary | std::ios_base::in);
119 boost::archive::binary_iarchive
a(data_file);
122 return !data_file.fail();
123 CATCH_ENTRY_L0(
"unserialize_obj_from_file",
false);
string a
Definition: MakeCryptoOps.py:15