Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions ros/src/foxglove_bridge/src/message_definition_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,12 @@ const MessageSpec& MessageDefinitionCache::load_message_spec(
}

// Get the package share directory, or throw a PackageNotFoundError
const std::string share_dir = ament_index_cpp::get_package_share_directory(package);
std::filesystem::path share_dir;
#if AMENT_INDEX_CPP_VERSION_GTE(1, 13, 0)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This macro should become available after ament/ament_index#105 merges

ament_index_cpp::get_package_share_directory(package, share_dir);
#else
share_dir = ament_index_cpp::get_package_share_directory(package);
#endif

// Get the rosidl_interfaces index contents for this package
std::string index_contents;
Expand All @@ -234,7 +239,7 @@ const MessageSpec& MessageDefinitionCache::load_message_spec(
}

// Read the file
const std::string full_path = share_dir + std::filesystem::path::preferred_separator + *it;
const auto full_path = share_dir / *it;
std::ifstream file{full_path};
if (!file.good()) {
throw DefinitionNotFoundError(definition_identifier.package_resource_name);
Expand Down
Loading