From: Wolfgang Bangerth Date: Thu, 18 Jul 2024 23:14:39 +0000 (-0600) Subject: Check that we can read from/write to streams. X-Git-Tag: v9.6.0-rc1~64^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ffea3e2520aaa6675df9e5d70130b0d0b7350018;p=dealii.git Check that we can read from/write to streams. --- diff --git a/source/grid/tria.cc b/source/grid/tria.cc index 183e9fc020..87623aa531 100644 --- a/source/grid/tria.cc +++ b/source/grid/tria.cc @@ -859,6 +859,7 @@ namespace internal std::string(file_basename) + "_fixed.data"; std::ofstream file(fname_fixed, std::ios::binary | std::ios::out); + AssertThrow(file.fail() == false, ExcIO()); // Write header data. file.write(reinterpret_cast( @@ -882,6 +883,7 @@ namespace internal std::ofstream file(fname_variable, std::ios::binary | std::ios::out); + AssertThrow(file.fail() == false, ExcIO()); // Write header data. file.write(reinterpret_cast( @@ -1075,6 +1077,8 @@ namespace internal std::string(file_basename) + "_fixed.data"; std::ifstream file(fname_fixed, std::ios::binary | std::ios::in); + AssertThrow(file.fail() == false, ExcIO()); + sizes_fixed_cumulative.resize(1 + n_attached_deserialize_fixed + (variable_size_data_stored ? 1 : 0)); @@ -1102,6 +1106,7 @@ namespace internal std::string(file_basename) + "_variable.data"; std::ifstream file(fname_variable, std::ios::binary | std::ios::in); + AssertThrow(file.fail() == false, ExcIO()); // Read header data. dest_sizes_variable.resize(local_num_cells); @@ -13726,7 +13731,9 @@ DEAL_II_CXX20_REQUIRES((concepts::is_valid_dim_spacedim)) void Triangulation::load(const std::string &file_basename) { // Load triangulation information. - std::ifstream ifs(file_basename + "_triangulation.data"); + std::ifstream ifs(file_basename + "_triangulation.data"); + AssertThrow(ifs.fail() == false, ExcIO()); + boost::archive::text_iarchive ia(ifs, boost::archive::no_header); load(ia, 0);