diff options
author | erwincoumans <erwincoumans@google.com> | 2020-08-11 08:28:08 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-11 08:28:08 -0700 |
commit | b2a473da1949f22bffb9839e536b3991276ecf8b (patch) | |
tree | 470be33326501cb5b417960cbe8a5454d904a63a | |
parent | ed9c8fca217c4d6ccf490a7fe1d6d8d4d17758f7 (diff) | |
parent | fc676c02c99c84a18d34592c88101458474babfe (diff) | |
download | bullet3-b2a473da1949f22bffb9839e536b3991276ecf8b.tar.gz |
Merge pull request #2980 from sippeyxp/find_file_logic
Simplify logic for searching files in UrdfFindMeshFile and prioritize…
-rw-r--r-- | examples/Importers/ImportURDFDemo/UrdfFindMeshFile.h | 41 |
1 files changed, 14 insertions, 27 deletions
diff --git a/examples/Importers/ImportURDFDemo/UrdfFindMeshFile.h b/examples/Importers/ImportURDFDemo/UrdfFindMeshFile.h index 147d8c911..3050cadde 100644 --- a/examples/Importers/ImportURDFDemo/UrdfFindMeshFile.h +++ b/examples/Importers/ImportURDFDemo/UrdfFindMeshFile.h @@ -63,48 +63,35 @@ static bool UrdfFindMeshFile( fn = fn.substr(drop_it_model.length()); std::list<std::string> shorter; - shorter.push_back("../.."); - shorter.push_back(".."); - shorter.push_back("."); + shorter.push_back("../../"); + shorter.push_back("../"); + shorter.push_back("./"); int cnt = urdf_path.size(); for (int i = 0; i < cnt; ++i) { if (urdf_path[i] == '/' || urdf_path[i] == '\\') { - shorter.push_back(urdf_path.substr(0, i)); + shorter.push_back(urdf_path.substr(0, i) + "/"); } } + shorter.push_back(""); // no prefix shorter.reverse(); std::string existing_file; - - + for (std::list<std::string>::iterator x = shorter.begin(); x != shorter.end(); ++x) { - for (std::list<std::string>::iterator x = shorter.begin(); x != shorter.end(); ++x) - { - std::string attempt = *x + "/" + fn; - int f = fileIO->fileOpen(attempt.c_str(), "rb"); - if (f<0) - { - //b3Printf("%s: tried '%s'", error_message_prefix.c_str(), attempt.c_str()); - continue; - } - fileIO->fileClose(f); - existing_file = attempt; - //b3Printf("%s: found '%s'", error_message_prefix.c_str(), attempt.c_str()); - break; - } - } - if (existing_file.empty()) - { - std::string attempt = fn; + std::string attempt = *x + fn; int f = fileIO->fileOpen(attempt.c_str(), "rb"); - if (f>=0) + if (f<0) { - existing_file = attempt; - fileIO->fileClose(f); + //b3Printf("%s: tried '%s'", error_message_prefix.c_str(), attempt.c_str()); + continue; } + fileIO->fileClose(f); + existing_file = attempt; + //b3Printf("%s: found '%s'", error_message_prefix.c_str(), attempt.c_str()); + break; } if (existing_file.empty()) |