This repository was archived by the owner on Nov 30, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change 27
27
#include < string>
28
28
#include < unordered_set>
29
29
#include < utility>
30
+ #include < filesystem>
30
31
31
32
namespace rosbag2_storage_mcap ::internal {
32
33
@@ -133,12 +134,22 @@ const MessageSpec& MessageDefinitionCache::load_message_spec(
133
134
}
134
135
std::string package = match[1 ];
135
136
std::string share_dir = ament_index_cpp::get_package_share_directory (package);
136
- std::ifstream file{share_dir + " /msg/" + match[2 ].str () +
137
- extension_for_format (definition_identifier.format )};
138
- if (!file.good ()) {
137
+ std::string target_file_name = match[2 ].str () + extension_for_format (definition_identifier.format );
138
+ std::string target_file_path;
139
+ // Recursively search install path for required file
140
+ // Depending on user setup, all .msg files could be present in <package_name>/msg/*.msg or <package_name>/<custom_name>/*.msg
141
+ for (auto & file : std::filesystem::recursive_directory_iterator (share_dir)) {
142
+ std::string found_file_name = file.path ().filename ();
143
+ if (found_file_name == target_file_name) {
144
+ target_file_path = file.path ().string ();
145
+ break ;
146
+ }
147
+ }
148
+ if (target_file_path.empty ()) {
139
149
throw DefinitionNotFoundError (definition_identifier.package_resource_name );
140
150
}
141
151
152
+ std::ifstream file{target_file_path};
142
153
std::string contents{std::istreambuf_iterator (file), {}};
143
154
const MessageSpec& spec =
144
155
msg_specs_by_definition_identifier_
You can’t perform that action at this time.
0 commit comments