std::vector GetRosbagsToUpload()

in rosbag_cloud_recorders/src/utils/file_utils.cpp [181:202]


std::vector<std::string> GetRosbagsToUpload(const std::string& search_directory, const std::function<bool (rosbag::View&)>& select_file)
{
  std::vector<std::string> ros_bags_to_upload;
  using boost::filesystem::directory_iterator;
  boost::filesystem::path ros_bag_search_path(search_directory);
  for (auto dir_entry = directory_iterator(ros_bag_search_path); dir_entry != directory_iterator(); dir_entry++) {
    if (boost::filesystem::is_directory(dir_entry->path())) {
      continue;
    }
    if (dir_entry->path().extension().string() == ".bag") {
      rosbag::Bag ros_bag;
      ros_bag.open(dir_entry->path().string());
      rosbag::View view_rosbag(ros_bag);
      if (select_file(view_rosbag)){
        ros_bags_to_upload.push_back(dir_entry->path().string());
        AWS_LOG_INFO(__func__, "Adding bag: [%s] to list of bag files to upload.", dir_entry->path().string().c_str());
      }
      ros_bag.close();
    }
  }
  return ros_bags_to_upload;
}