33 #include <boost/archive/binary_iarchive.hpp> 34 #include <boost/archive/portable_binary_oarchive.hpp> 35 #include <boost/archive/portable_binary_iarchive.hpp> 36 #include <boost/filesystem/operations.hpp> 41 template<
class t_
object>
47 HANDLE data_file_handle = ::CreateFile(file_path.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
48 if (INVALID_HANDLE_VALUE == data_file_handle)
51 int data_file_descriptor = _open_osfhandle((intptr_t)data_file_handle, 0);
52 if (-1 == data_file_descriptor)
54 ::CloseHandle(data_file_handle);
58 const std::unique_ptr<FILE, tools::close_file> data_file_file{_fdopen(data_file_descriptor,
"wb")};
59 if (
nullptr == data_file_file)
62 _close(data_file_descriptor);
67 std::ofstream data_file(data_file_file.get());
74 std::ofstream data_file;
75 data_file.open(file_path , std::ios_base::binary | std::ios_base::out| std::ios::trunc);
80 boost::archive::portable_binary_oarchive
a(data_file);
88 ::FlushFileBuffers(data_file_handle);
92 CATCH_ENTRY_L0(
"serialize_obj_to_file",
false);
95 template<
class t_
object>
100 std::ifstream data_file;
101 data_file.open( file_path, std::ios_base::binary | std::ios_base::in);
107 boost::archive::portable_binary_iarchive
a(data_file);
113 boost::filesystem::copy_file(file_path, file_path +
".unportable", boost::filesystem::copy_option::overwrite_if_exists);
115 data_file.open( file_path, std::ios_base::binary | std::ios_base::in);
118 boost::archive::binary_iarchive
a(data_file);
121 return !data_file.fail();
122 CATCH_ENTRY_L0(
"unserialize_obj_from_file",
false);
string a
Definition: MakeCryptoOps.py:15