Fix logic for looking up root model within an archive.

PiperOrigin-RevId: 881976329
Change-Id: I7771b84ff0aed83d55ee830deb2f92357355eb88
This commit is contained in:
Haroon Qureshi
2026-03-11 06:17:35 -07:00
committed by Copybara-Service
parent df02fe4bc0
commit ed2f34baa0
+2 -2
View File
@@ -74,11 +74,11 @@ class ZipArchiveProvider : public mjpResourceProvider {
// Look for the root XML model in the archive. First look for an XML file
// with the same name as the archive itself. Failing that, look for an XML
// file with the same name including the parent directory.
// file within a subdirectory with the same name as the archive.
const std::filesystem::path path(name_);
root_model_ = (path / path.stem()).string() + ".xml";
if (!Contains(root_model_)) {
root_model_ = (path / path.parent_path() / path.stem()).string() + ".xml";
root_model_ = (path / path.stem() / path.stem()).string() + ".xml";
if (!Contains(root_model_)) {
SetError(error, error_sz, "Zip error: no root XML file found.");
return;