summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErwin Coumans <erwincoumans@google.com>2019-05-29 19:26:27 -0700
committerErwin Coumans <erwincoumans@google.com>2019-05-29 19:26:27 -0700
commit411ac4fcc3705b161691917d6d7aba05505079da (patch)
tree55f2a79eb201a029c00c574013ace3394fcfdc2e
parent093986f1ee60a2bf9c759a7729b137daab7b8bd3 (diff)
downloadbullet3-411ac4fcc3705b161691917d6d7aba05505079da.tar.gz
fix loadMJCF/BulletMJCFImporter to load from fileIO
-rw-r--r--examples/Importers/ImportMJCFDemo/BulletMJCFImporter.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/examples/Importers/ImportMJCFDemo/BulletMJCFImporter.cpp b/examples/Importers/ImportMJCFDemo/BulletMJCFImporter.cpp
index e41901674..253a338e0 100644
--- a/examples/Importers/ImportMJCFDemo/BulletMJCFImporter.cpp
+++ b/examples/Importers/ImportMJCFDemo/BulletMJCFImporter.cpp
@@ -9,9 +9,9 @@
#include "../../CommonInterfaces/CommonFileIOInterface.h"
#include "../ImportURDFDemo/UrdfFindMeshFile.h"
#include <string>
-#include "../../Utils/b3ResourcePath.h"
#include <iostream>
#include <fstream>
+#include "../../Utils/b3ResourcePath.h"
#include "../ImportURDFDemo/URDF2Bullet.h"
#include "../ImportURDFDemo/UrdfParser.h"
#include "../ImportURDFDemo/urdfStringSplit.h"
@@ -1453,17 +1453,21 @@ bool BulletMJCFImporter::loadMJCF(const char* fileName, MJCFErrorLogger* logger,
}
else
{
- int maxPathLen = 1024;
- fu.extractPath(relativeFileName, m_data->m_pathPrefix, maxPathLen);
+ //read file
+ int fileId = m_data->m_fileIO->fileOpen(relativeFileName,"r");
- std::fstream xml_file(relativeFileName, std::fstream::in);
- while (xml_file.good())
+ char destBuffer[8192];
+ char* line = 0;
+ do
{
- std::string line;
- std::getline(xml_file, line);
- xml_string += (line + "\n");
+ line = m_data->m_fileIO->readLine(fileId, destBuffer, 8192);
+ if (line)
+ {
+ xml_string += (std::string(destBuffer) + "\n");
+ }
}
- xml_file.close();
+ while (line);
+ m_data->m_fileIO->fileClose(fileId);
if (parseMJCFString(xml_string.c_str(), logger))
{