Add VFS handling logic to mj_openResource.
PiperOrigin-RevId: 653124909 Change-Id: I4d031eb0bfb0070f8493753d2aeaac60ac283b85
This commit is contained in:
committed by
Copybara-Service
parent
7f46e936f6
commit
2cf352c2e6
+7
-9
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "xml/xml_api.h"
|
||||
|
||||
#include <array>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
@@ -186,15 +187,12 @@ int mj_printSchema(const char* filename, char* buffer, int buffer_sz, int flg_ht
|
||||
|
||||
// load model from binary MJB resource
|
||||
mjModel* mj_loadModel(const char* filename, const mjVFS* vfs) {
|
||||
mjResource* resource = nullptr;
|
||||
|
||||
// first try vfs, otherwise try a provider or OS filesystem
|
||||
if (!(resource = mju_openVfsResource(filename, vfs))) {
|
||||
char error[1024];
|
||||
if (!(resource = mju_openResource(filename, error, 1024))) {
|
||||
mju_warning("%s", error);
|
||||
return nullptr;
|
||||
}
|
||||
std::array<char, 1024> error;
|
||||
mjResource* resource = mju_openResource(filename, vfs,
|
||||
error.data(), error.size());
|
||||
if (resource == nullptr) {
|
||||
mju_warning("%s", error.data());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const void* buffer = NULL;
|
||||
|
||||
Reference in New Issue
Block a user