Skip to content

Commit

Permalink
replace deprecated boost filesystem extension (#5904)
Browse files Browse the repository at this point in the history
* replace deprecated boost filesystem extension

* fix format error

* replace more boost extension functions
  • Loading branch information
cybaol authored Dec 20, 2023
1 parent 1b383d9 commit eccdbe8
Show file tree
Hide file tree
Showing 26 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion apps/in_hand_scanner/src/offline_integration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ pcl::ihs::OfflineIntegration::getFilesFromDirectory(
boost::filesystem::directory_iterator it_end;
for (boost::filesystem::directory_iterator it(path_dir); it != it_end; ++it) {
if (!is_directory(it->status()) &&
boost::algorithm::to_upper_copy(boost::filesystem::extension(it->path())) ==
boost::algorithm::to_upper_copy(it->path().extension().string()) ==
boost::algorithm::to_upper_copy(extension)) {
files.push_back(it->path().string());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ loadFeatureModels (const boost::filesystem::path &base_dir, const std::string &e
pcl::console::print_highlight ("Loading %s (%lu models loaded so far).\n", ss.str ().c_str (), (unsigned long)models.size ());
loadFeatureModels (it->path (), extension, models);
}
if (boost::filesystem::is_regular_file (it->status ()) && boost::filesystem::extension (it->path ()) == extension)
if (boost::filesystem::is_regular_file (it->status ()) && it->path ().extension ().string () == extension)
{
vfh_model m;
if (loadHist (base_dir / it->path ().filename (), m))
Expand Down
2 changes: 1 addition & 1 deletion gpu/kinfu/tools/kinfu_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ std::vector<std::string> getPcdFilesInDir(const std::string& directory)

for(; pos != end ; ++pos)
if (fs::is_regular_file(pos->status()) )
if (fs::extension(*pos) == ".pcd")
if (pos->path().extension().string() == ".pcd")
{
result.push_back (pos->path ().string ());
std::cout << "added: " << result.back() << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion gpu/kinfu_large_scale/tools/kinfuLS_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ std::vector<std::string> getPcdFilesInDir(const std::string& directory)

for(; pos != end ; ++pos)
if (fs::is_regular_file(pos->status()) )
if (fs::extension(*pos) == ".pcd")
if (pos->path().extension().string() == ".pcd")
{
result.push_back (pos->path ().string ());
std::cout << "added: " << result.back() << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion gpu/kinfu_large_scale/tools/standalone_texture_mapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ main (int argc, char** argv)
std::string extension (".txt");
for (boost::filesystem::directory_iterator it (base_dir); it != boost::filesystem::directory_iterator (); ++it)
{
if(boost::filesystem::is_regular_file (it->status ()) && boost::filesystem::extension (it->path ()) == extension)
if(boost::filesystem::is_regular_file (it->status ()) && it->path ().extension ().string () == extension)
{
pcl::TextureMapping<pcl::PointXYZ>::Camera cam;
readCamPoseFile(it->path ().string (), cam);
Expand Down
2 changes: 1 addition & 1 deletion gpu/people/tools/people_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ std::vector<std::string> getPcdFilesInDir(const std::string& directory)

for(; pos != end ; ++pos)
if (fs::is_regular_file(pos->status()) )
if (fs::extension(*pos) == ".pcd")
if (pos->path().extension().string() == ".pcd")
result.push_back(pos->path().string());

return result;
Expand Down
2 changes: 1 addition & 1 deletion io/src/ascii_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ pcl::ASCIIReader::readHeader (const std::string& file_name,
PCL_ERROR ("[%s] File %s does not exist.\n", name_.c_str (), file_name.c_str ());
return (-1);
}
if (boost::filesystem::extension (fpath) != extension_)
if (fpath.extension ().string () != extension_)
{
PCL_ERROR ("[%s] File does not have %s extension. \n", name_.c_str(), extension_.c_str());
return -1;
Expand Down
8 changes: 4 additions & 4 deletions io/src/image_grabber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ pcl::ImageGrabberBase::ImageGrabberImpl::loadDepthAndRGBFiles (const std::string
boost::filesystem::directory_iterator end_itr;
for (boost::filesystem::directory_iterator itr (dir); itr != end_itr; ++itr)
{
extension = boost::algorithm::to_upper_copy (boost::filesystem::extension (itr->path ()));
extension = boost::algorithm::to_upper_copy (itr->path ().extension ().string ());
pathname = itr->path ().string ();
basename = itr->path ().stem ().string ();
if (!boost::filesystem::is_directory (itr->status ())
Expand Down Expand Up @@ -310,7 +310,7 @@ pcl::ImageGrabberBase::ImageGrabberImpl::loadDepthAndRGBFiles (const std::string
// First iterate over depth images
for (boost::filesystem::directory_iterator itr (depth_dir); itr != end_itr; ++itr)
{
extension = boost::algorithm::to_upper_copy (boost::filesystem::extension (itr->path ()));
extension = boost::algorithm::to_upper_copy (itr->path ().extension ().string ());
pathname = itr->path ().string ();
basename = itr->path ().stem ().string ();
if (!boost::filesystem::is_directory (itr->status ())
Expand All @@ -325,7 +325,7 @@ pcl::ImageGrabberBase::ImageGrabberImpl::loadDepthAndRGBFiles (const std::string
// Then iterate over RGB images
for (boost::filesystem::directory_iterator itr (rgb_dir); itr != end_itr; ++itr)
{
extension = boost::algorithm::to_upper_copy (boost::filesystem::extension (itr->path ()));
extension = boost::algorithm::to_upper_copy (itr->path ().extension ().string ());
pathname = itr->path ().string ();
basename = itr->path ().stem ().string ();
if (!boost::filesystem::is_directory (itr->status ())
Expand Down Expand Up @@ -366,7 +366,7 @@ pcl::ImageGrabberBase::ImageGrabberImpl::loadPCLZFFiles (const std::string &dir)
boost::filesystem::directory_iterator end_itr;
for (boost::filesystem::directory_iterator itr (dir); itr != end_itr; ++itr)
{
extension = boost::algorithm::to_upper_copy (boost::filesystem::extension (itr->path ()));
extension = boost::algorithm::to_upper_copy (itr->path ().extension ().string ());
pathname = itr->path ().string ();
basename = itr->path ().stem ().string ();
if (!boost::filesystem::is_directory (itr->status ())
Expand Down
4 changes: 2 additions & 2 deletions outofcore/include/pcl/outofcore/impl/octree_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -699,9 +699,9 @@ namespace pcl
template<typename ContainerT, typename PointT> bool
OutofcoreOctreeBase<ContainerT, PointT>::checkExtension (const boost::filesystem::path& path_name)
{
if (boost::filesystem::extension (path_name) != OutofcoreOctreeBaseNode<ContainerT, PointT>::node_index_extension)
if (path_name.extension ().string () != OutofcoreOctreeBaseNode<ContainerT, PointT>::node_index_extension)
{
PCL_ERROR ( "[pcl::outofcore::OutofcoreOctreeBase] Wrong root node file extension: %s. The tree must have a root node ending in %s\n", boost::filesystem::extension (path_name).c_str (), OutofcoreOctreeBaseNode<ContainerT, PointT>::node_index_extension.c_str () );
PCL_ERROR ( "[pcl::outofcore::OutofcoreOctreeBase] Wrong root node file extension: %s. The tree must have a root node ending in %s\n", path_name.extension ().string ().c_str (), OutofcoreOctreeBaseNode<ContainerT, PointT>::node_index_extension.c_str () );
return (false);
}

Expand Down
4 changes: 2 additions & 2 deletions outofcore/include/pcl/outofcore/impl/octree_base_node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ namespace pcl

if (!boost::filesystem::is_directory (file))
{
if (boost::filesystem::extension (file) == node_index_extension)
if (file.extension ().string () == node_index_extension)
{
b_loaded = node_metadata_->loadMetadataFromDisk (file);
break;
Expand Down Expand Up @@ -2050,7 +2050,7 @@ namespace pcl
const boost::filesystem::path& file = *diter;
if (!boost::filesystem::is_directory (file))
{
if (boost::filesystem::extension (file) == OutofcoreOctreeBaseNode<ContainerT, PointT>::node_index_extension)
if (file.extension ().string () == OutofcoreOctreeBaseNode<ContainerT, PointT>::node_index_extension)
{
thisnode->thisnodeindex_ = file;
loaded = true;
Expand Down
2 changes: 1 addition & 1 deletion outofcore/tools/outofcore_print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ main (int argc, char* argv[])
const boost::filesystem::path& file = *diter;
if (!boost::filesystem::is_directory (file))
{
if (boost::filesystem::extension (file) == OctreeDiskNode::node_index_extension)
if (file.extension ().string () == OctreeDiskNode::node_index_extension)
{
tree_root = file;
}
Expand Down
2 changes: 1 addition & 1 deletion outofcore/tools/outofcore_viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ main (int argc, char* argv[])
const boost::filesystem::path& file = *diter;
if (!boost::filesystem::is_directory (file))
{
if (boost::filesystem::extension (file) == octree_disk_node::node_index_extension)
if (file.extension ().string () == octree_disk_node::node_index_extension)
{
tree_root = file;
}
Expand Down
2 changes: 1 addition & 1 deletion test/io/test_grabbers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ int
boost::filesystem::directory_iterator end_itr;
for (boost::filesystem::directory_iterator itr (pcd_dir_); itr != end_itr; ++itr)
{
if (!is_directory (itr->status ()) && boost::algorithm::to_upper_copy (boost::filesystem::extension (itr->path ())) == ".PCD" )
if (!is_directory (itr->status ()) && boost::algorithm::to_upper_copy (itr->path ().extension ().string ()) == ".PCD" )
{
pcd_files_.push_back (itr->path ().string ());
std::cout << "added: " << itr->path ().string () << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion tools/fast_bilateral_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ main (int argc, char** argv)
for (boost::filesystem::directory_iterator itr (input_dir); itr != end_itr; ++itr)
{
// Only add PCD files
if (!is_directory (itr->status ()) && boost::algorithm::to_upper_copy (boost::filesystem::extension (itr->path ())) == ".PCD" )
if (!is_directory (itr->status ()) && boost::algorithm::to_upper_copy (itr->path ().extension ().string ()) == ".PCD" )
{
pcd_files.push_back (itr->path ().string ());
PCL_INFO ("[Batch processing mode] Added %s for processing.\n", itr->path ().string ().c_str ());
Expand Down
2 changes: 1 addition & 1 deletion tools/grid_min.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ main (int argc, char** argv)
for (boost::filesystem::directory_iterator itr (input_dir); itr != end_itr; ++itr)
{
// Only add PCD files
if (!is_directory (itr->status ()) && boost::algorithm::to_upper_copy (boost::filesystem::extension (itr->path ())) == ".PCD" )
if (!is_directory (itr->status ()) && boost::algorithm::to_upper_copy (itr->path ().extension ().string ()) == ".PCD" )
{
pcd_files.push_back (itr->path ().string ());
PCL_INFO ("[Batch processing mode] Added %s for processing.\n", itr->path ().string ().c_str ());
Expand Down
2 changes: 1 addition & 1 deletion tools/local_max.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ main (int argc, char** argv)
for (boost::filesystem::directory_iterator itr (input_dir); itr != end_itr; ++itr)
{
// Only add PCD files
if (!is_directory (itr->status ()) && boost::algorithm::to_upper_copy (boost::filesystem::extension (itr->path ())) == ".PCD" )
if (!is_directory (itr->status ()) && boost::algorithm::to_upper_copy (itr->path ().extension ().string ()) == ".PCD" )
{
pcd_files.push_back (itr->path ().string ());
PCL_INFO ("[Batch processing mode] Added %s for processing.\n", itr->path ().string ().c_str ());
Expand Down
2 changes: 1 addition & 1 deletion tools/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ main (int argc, char** argv)
for (boost::filesystem::directory_iterator itr (input_dir); itr != end_itr; ++itr)
{
// Only add PCD files
if (!is_directory (itr->status ()) && boost::algorithm::to_upper_copy (boost::filesystem::extension (itr->path ())) == ".PCD" )
if (!is_directory (itr->status ()) && boost::algorithm::to_upper_copy (itr->path ().extension ().string ()) == ".PCD" )
{
pcd_files.push_back (itr->path ().string ());
PCL_INFO ("[Batch processing mode] Added %s for processing.\n", itr->path ().string ().c_str ());
Expand Down
2 changes: 1 addition & 1 deletion tools/normal_estimation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ main (int argc, char** argv)
for (boost::filesystem::directory_iterator itr (input_dir); itr != end_itr; ++itr)
{
// Only add PCD files
if (!is_directory (itr->status ()) && boost::algorithm::to_upper_copy (boost::filesystem::extension (itr->path ())) == ".PCD" )
if (!is_directory (itr->status ()) && boost::algorithm::to_upper_copy (itr->path ().extension ().string ()) == ".PCD" )
{
pcd_files.push_back (itr->path ().string ());
PCL_INFO ("[Batch processing mode] Added %s for processing.\n", itr->path ().string ().c_str ());
Expand Down
2 changes: 1 addition & 1 deletion tools/passthrough_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ main (int argc, char** argv)
for (boost::filesystem::directory_iterator itr (input_dir); itr != end_itr; ++itr)
{
// Only add PCD files
if (!is_directory (itr->status ()) && boost::algorithm::to_upper_copy (boost::filesystem::extension (itr->path ())) == ".PCD" )
if (!is_directory (itr->status ()) && boost::algorithm::to_upper_copy (itr->path ().extension ().string ()) == ".PCD" )
{
pcd_files.push_back (itr->path ().string ());
PCL_INFO ("[Batch processing mode] Added %s for processing.\n", itr->path ().string ().c_str ());
Expand Down
2 changes: 1 addition & 1 deletion tools/pcd_grabber_viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ main (int argc, char** argv)
boost::filesystem::directory_iterator end_itr;
for (boost::filesystem::directory_iterator itr (path); itr != end_itr; ++itr)
{
if (!is_directory (itr->status ()) && boost::algorithm::to_upper_copy (boost::filesystem::extension (itr->path ())) == ".PCD" )
if (!is_directory (itr->status ()) && boost::algorithm::to_upper_copy (itr->path ().extension ().string ()) == ".PCD" )
{
pcd_files.push_back (itr->path ().string ());
std::cout << "added: " << itr->path ().string () << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion tools/progressive_morphological_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ main (int argc, char** argv)
for (boost::filesystem::directory_iterator itr (input_dir); itr != end_itr; ++itr)
{
// Only add PCD files
if (!is_directory (itr->status ()) && boost::algorithm::to_upper_copy (boost::filesystem::extension (itr->path ())) == ".PCD" )
if (!is_directory (itr->status ()) && boost::algorithm::to_upper_copy (itr->path ().extension ().string ()) == ".PCD" )
{
pcd_files.push_back (itr->path ().string ());
PCL_INFO ("[Batch processing mode] Added %s for processing.\n", itr->path ().string ().c_str ());
Expand Down
2 changes: 1 addition & 1 deletion tools/radius_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ main (int argc, char** argv)
for (boost::filesystem::directory_iterator itr (input_dir); itr != end_itr; ++itr)
{
// Only add PCD files
if (!is_directory (itr->status ()) && boost::algorithm::to_upper_copy (boost::filesystem::extension (itr->path ())) == ".PCD" )
if (!is_directory (itr->status ()) && boost::algorithm::to_upper_copy (itr->path ().extension ().string ()) == ".PCD" )
{
pcd_files.push_back (itr->path ().string ());
PCL_INFO ("[Batch processing mode] Added %s for processing.\n", itr->path ().string ().c_str ());
Expand Down
2 changes: 1 addition & 1 deletion tools/sac_segmentation_plane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ main (int argc, char** argv)
for (boost::filesystem::directory_iterator itr (input_dir); itr != end_itr; ++itr)
{
// Only add PCD files
if (!is_directory (itr->status ()) && boost::algorithm::to_upper_copy (boost::filesystem::extension (itr->path ())) == ".PCD" )
if (!is_directory (itr->status ()) && boost::algorithm::to_upper_copy (itr->path ().extension ().string ()) == ".PCD" )
{
pcd_files.push_back (itr->path ().string ());
PCL_INFO ("[Batch processing mode] Added %s for processing.\n", itr->path ().string ().c_str ());
Expand Down
2 changes: 1 addition & 1 deletion tools/unary_classifier_segment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ loadTrainedFeatures (std::vector<FeatureT::Ptr> &out,
for (boost::filesystem::directory_iterator it (base_dir); it != boost::filesystem::directory_iterator (); ++it)
{
if (!boost::filesystem::is_directory (it->status ()) &&
boost::filesystem::extension (it->path ()) == ".pcd")
it->path ().extension ().string () == ".pcd")
{
const std::string path = it->path ().string ();

Expand Down
2 changes: 1 addition & 1 deletion tools/uniform_sampling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ saveCloud (const std::string &filename, const pcl::PCLPointCloud2 &output)

PCDWriter w_pcd;
PLYWriter w_ply;
std::string output_ext = boost::filesystem::extension (filename);
std::string output_ext = boost::filesystem::path (filename).extension ().string ();
std::transform (output_ext.begin (), output_ext.end (), output_ext.begin (), ::tolower);

if (output_ext == ".pcd")
Expand Down
4 changes: 2 additions & 2 deletions tools/virtual_scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
#include <vtkMath.h>

#include <boost/algorithm/string.hpp> // for boost::is_any_of, boost::split, boost::token_compress_on, boost::trim
#include <boost/filesystem.hpp> // for boost::filesystem::create_directories, boost::filesystem::exists, boost::filesystem::extension, boost::filesystem::path
#include <boost/filesystem.hpp> // for boost::filesystem::create_directories, boost::filesystem::exists, boost::filesystem::path, boost::filesystem::path::extension

using namespace pcl;

Expand All @@ -87,7 +87,7 @@ struct ScanParameters
vtkPolyData*
loadDataSet (const char* file_name)
{
std::string extension = boost::filesystem::extension (file_name);
std::string extension = boost::filesystem::path (file_name).extension ().string ();
if (extension == ".ply")
{
vtkPLYReader* reader = vtkPLYReader::New ();
Expand Down

0 comments on commit eccdbe8

Please sign in to comment.