39 #ifndef PCL_COMMON_FILE_IO_IMPL_HPP_
40 #define PCL_COMMON_FILE_IO_IMPL_HPP_
42 #include <pcl/common/pcl_filesystem.h>
44 #include <boost/range/iterator_range.hpp>
57 pcl_fs::path p(directory);
58 if(pcl_fs::is_directory(p))
60 for(
const auto& entry : boost::make_iterator_range(pcl_fs::directory_iterator(p), {}))
62 if (pcl_fs::is_regular_file(entry))
64 if (entry.path().extension() ==
".pcd")
65 file_names.emplace_back(entry.path().filename().string());
71 std::cerr <<
"Given path is not a directory\n";
74 std::sort(file_names.begin(), file_names.end());
79 std::size_t filename_start = input.find_last_of(
'/',
static_cast<std::size_t
>(-1)) + 1;
80 return input.substr(filename_start, input.size()-filename_start);
85 std::size_t dot_position = input.find_last_of(
'.', input.size());
86 return input.substr(0, dot_position);
91 std::size_t dot_position = input.find_last_of(
'.', input.size());
92 return input.substr(dot_position+1, input.size());
void getAllPcdFilesInDirectory(const std::string &directory, std::vector< std::string > &file_names)
Find all *.pcd files in the directory and return them sorted.
std::string getFilenameWithoutPath(const std::string &input)
Remove the path from the given string and return only the filename (the remaining string after the la...
std::string getFileExtension(const std::string &input)
Get the file extension from the given string (the remaining string after the last '.
std::string getFilenameWithoutExtension(const std::string &input)
Remove the extension from the given string and return only the filename (everything before the last '...