Skip to content

Commit

Permalink
(PointSetIO) Check successful write (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
csparker247 authored Oct 31, 2023
1 parent 63aecd9 commit efc8bf2
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions core/include/vc/core/io/PointSetIO.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,13 @@ class PointSetIO
}
outfile << std::endl;
}

outfile.flush();
outfile.close();
if (outfile.fail()) {
auto msg = "failure writing file '" + path.string() + "'";
throw IOException(msg);
}
}

/** @brief Write a binary PointSet */
Expand All @@ -499,6 +506,13 @@ class PointSetIO
auto nbytes = T::channels * sizeof(typename T::value_type);
outfile.write(reinterpret_cast<const char*>(p.val), nbytes);
}

outfile.flush();
outfile.close();
if (outfile.fail()) {
auto msg = "failure writing file '" + path.string() + "'";
throw IOException(msg);
}
}

/** @brief Write an ASCII OrderedPointSet */
Expand All @@ -519,6 +533,13 @@ class PointSetIO
}
outfile << std::endl;
}

outfile.flush();
outfile.close();
if (outfile.fail()) {
auto msg = "failure writing file '" + path.string() + "'";
throw IOException(msg);
}
}

/** @brief Write a binary OrderedPointSet */
Expand All @@ -538,6 +559,13 @@ class PointSetIO
auto nbytes = T::channels * sizeof(typename T::value_type);
outfile.write(reinterpret_cast<const char*>(p.val), nbytes);
}

outfile.flush();
outfile.close();
if (outfile.fail()) {
auto msg = "failure writing file '" + path.string() + "'";
throw IOException(msg);
}
}
/**@}*/
};
Expand Down

0 comments on commit efc8bf2

Please sign in to comment.