diff --git a/Point_set_3/include/CGAL/Point_set_3/IO.h b/Point_set_3/include/CGAL/Point_set_3/IO.h index 287cf45e728..6d6e3acb2aa 100644 --- a/Point_set_3/include/CGAL/Point_set_3/IO.h +++ b/Point_set_3/include/CGAL/Point_set_3/IO.h @@ -394,7 +394,10 @@ read_ply_point_set( internal::PLY::Point_set_3_filler filler(point_set); if (!(reader.init (stream))) + { + stream.setstate(std::ios::failbit); return false; + } if (comments != NULL) *comments = reader.comments(); @@ -415,8 +418,7 @@ read_ply_point_set( { internal::PLY::PLY_read_number* property = element.property(k); property->get (stream); - - if (stream.eof()) + if (stream.fail()) return false; } @@ -425,7 +427,7 @@ read_ply_point_set( } } - return !stream.bad(); + return true; } /*! diff --git a/Point_set_processing_3/include/CGAL/IO/read_ply_points.h b/Point_set_processing_3/include/CGAL/IO/read_ply_points.h index 11409af4abb..a7cc94683ca 100644 --- a/Point_set_processing_3/include/CGAL/IO/read_ply_points.h +++ b/Point_set_processing_3/include/CGAL/IO/read_ply_points.h @@ -765,7 +765,10 @@ bool read_ply_points_with_properties (std::istream& stream, internal::PLY::PLY_reader reader; if (!(reader.init (stream))) + { + stream.setstate(std::ios::failbit); return false; + } for (std::size_t i = 0; i < reader.number_of_elements(); ++ i) { @@ -778,7 +781,7 @@ bool read_ply_points_with_properties (std::istream& stream, internal::PLY::PLY_read_number* property = element.property(k); property->get (stream); - if (stream.eof()) + if (stream.fail()) return false; } diff --git a/Polyhedron_IO/include/CGAL/IO/PLY_reader.h b/Polyhedron_IO/include/CGAL/IO/PLY_reader.h index 36b8a16fef1..2f7522c36fd 100644 --- a/Polyhedron_IO/include/CGAL/IO/PLY_reader.h +++ b/Polyhedron_IO/include/CGAL/IO/PLY_reader.h @@ -54,7 +54,7 @@ namespace CGAL{ internal::PLY::PLY_read_number* property = element.property(k); property->get (in); - if (in.eof()) + if (in.fail()) return false; } @@ -84,7 +84,7 @@ namespace CGAL{ polygons.back()[i] = std::size_t(get<0>(new_face)[i]); } - return !in.bad(); + return true; } } @@ -106,7 +106,10 @@ namespace CGAL{ internal::PLY::PLY_reader reader; if (!(reader.init (in))) + { + in.setstate(std::ios::failbit); return false; + } for (std::size_t i = 0; i < reader.number_of_elements(); ++ i) { @@ -121,7 +124,7 @@ namespace CGAL{ internal::PLY::PLY_read_number* property = element.property(k); property->get (in); - if (in.eof()) + if (in.fail()) return false; } @@ -160,14 +163,14 @@ namespace CGAL{ internal::PLY::PLY_read_number* property = element.property(k); property->get (in); - if (in.eof()) + if (in.fail()) return false; } } } } - return !in.bad(); + return true; } template @@ -187,7 +190,10 @@ namespace CGAL{ internal::PLY::PLY_reader reader; if (!(reader.init (in))) + { + in.setstate(std::ios::failbit); return false; + } for (std::size_t i = 0; i < reader.number_of_elements(); ++ i) { @@ -215,7 +221,7 @@ namespace CGAL{ internal::PLY::PLY_read_number* property = element.property(k); property->get (in); - if (in.eof()) + if (in.fail()) return false; } @@ -266,14 +272,14 @@ namespace CGAL{ internal::PLY::PLY_read_number* property = element.property(k); property->get (in); - if (in.eof()) + if (in.fail()) return false; } } } } - return !in.bad(); + return true; }