Add various improvements for resource providers.

PiperOrigin-RevId: 529706437
Change-Id: I20385e031446674584349c301982dbe13b812477
This commit is contained in:
Kyle Bayes
2023-05-05 07:02:51 -07:00
committed by Copybara-Service
parent b798f89212
commit 67f0f5154f
23 changed files with 576 additions and 193 deletions
+7 -19
View File
@@ -22,6 +22,7 @@
#include <string_view>
#include <mujoco/mjtnum.h>
#include <mujoco/mujoco.h>
#include "engine/engine_macro.h"
#include "engine/engine_util_spatial.h"
@@ -558,6 +559,12 @@ bool mjuu_isabspath(string path) {
return false;
}
// path is scheme:filename which we consider an absolute path
// e.g. file URI's are always absolute paths
if (mjp_getResourceProvider(path.c_str()) != nullptr) {
return true;
}
// check first char
const char* str = path.c_str();
if (str[0]=='\\' || str[0]=='/') {
@@ -573,25 +580,6 @@ bool mjuu_isabspath(string path) {
}
// get directory path of file
string mjuu_getfiledir(string filename) {
// no filename
if (filename.empty()) {
return "";
}
// find last pathsymbol
size_t last = filename.find_last_of("/\\");
// no pathsymbol: unknown dir
if (last==string::npos) {
return "";
}
// extract path from filename
return filename.substr(0, last+1);
}
// assemble full filename
string mjuu_makefullname(string filedir, string meshdir, string filename) {