Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ros2]: Improve finding of message file #100

Merged
merged 2 commits into from
Dec 1, 2022
Merged
Changes from 1 commit
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
5 changes: 3 additions & 2 deletions ros2_foxglove_bridge/src/message_definition_cache.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "foxglove_bridge/message_definition_cache.hpp"

#include <filesystem>
achim-k marked this conversation as resolved.
Show resolved Hide resolved
#include <fstream>
#include <optional>
#include <regex>
Expand Down Expand Up @@ -155,8 +156,8 @@ const MessageSpec& MessageDefinitionCache::load_message_spec(
// Find the first line that ends with the filename we're looking for
const auto lines = split_string(index_contents);
const auto it = std::find_if(lines.begin(), lines.end(), [&filename](const std::string& line) {
return line.size() >= filename.size() &&
line.compare(line.size() - filename.size(), filename.size(), filename) == 0;
std::filesystem::path filePath(line);
return filePath.filename() == filename;
});
if (it == lines.end()) {
throw DefinitionNotFoundError(definition_identifier.package_resource_name);
Expand Down