From 66060b7522ef1c3b82c556f6e0c83787002c3c60 Mon Sep 17 00:00:00 2001 From: xkaraman Date: Mon, 10 Jun 2019 19:58:31 +0300 Subject: [PATCH] Add descriptive error file not found --- io/src/ply_io.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/io/src/ply_io.cpp b/io/src/ply_io.cpp index 61b563c9e17..1e057e3ecad 100644 --- a/io/src/ply_io.cpp +++ b/io/src/ply_io.cpp @@ -46,6 +46,12 @@ #include #include +// https://www.boost.org/doc/libs/1_70_0/libs/filesystem/doc/index.htm#Coding-guidelines +#define BOOST_FILESYSTEM_NO_DEPRECATED +#include + +namespace fs = boost::filesystem; + boost::tuple, std::function > pcl::PLYReader::elementDefinitionCallback (const std::string& element_name, std::size_t count) { @@ -602,6 +608,12 @@ pcl::PLYReader::read (const std::string &file_name, pcl::PCLPointCloud2 &cloud, int data_type; unsigned int data_idx; + if (!fs::exists (file_name)) + { + PCL_ERROR ("[pcl::PLYReader::read] File (%s) not found!\n",file_name.c_str ()); + return (-1); + } + if (this->readHeader (file_name, cloud, origin, orientation, ply_version, data_type, data_idx)) { PCL_ERROR ("[pcl::PLYReader::read] problem parsing header!\n"); @@ -662,6 +674,13 @@ pcl::PLYReader::read (const std::string &file_name, pcl::PolygonMesh &mesh, int data_type; unsigned int data_idx; polygons_ = &(mesh.polygons); + + if (!fs::exists (file_name)) + { + PCL_ERROR ("[pcl::PLYReader::read] File (%s) not found!\n",file_name.c_str ()); + return (-1); + } + if (this->readHeader (file_name, mesh.cloud, origin, orientation, ply_version, data_type, data_idx, offset)) { PCL_ERROR ("[pcl::PLYReader::read] problem parsing header!\n");