X3D importer: Fixed path handling

This commit is contained in:
Patrick Dähne
2017-07-11 19:41:24 +02:00
parent 457dff1bf1
commit 8959bcb847
2 changed files with 10 additions and 3 deletions

View File

@@ -51,9 +51,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Header files, Assimp.
#include <assimp/DefaultIOSystem.h>
#include <regex>
namespace Assimp
{
static std::regex pattern_parentDir(R"((^|/)[^/]+/../)");
// <Inline
// DEF="" ID
// USE="" IDREF
@@ -91,9 +95,10 @@ void X3DImporter::ParseNode_Networking_Inline()
{
std::string full_path;
full_path = mpIOHandler->CurrentDirectory() + "/" + url.front();
full_path = std::regex_replace(mpIOHandler->CurrentDirectory() + url.front(), pattern_parentDir, "$1");
// Attribute "url" can contain list of strings. But we need only one - first.
mpIOHandler->PushDirectory(DefaultIOSystem::absolutePath(full_path));
std::string::size_type slashPos = full_path.find_last_of("\\/");
mpIOHandler->PushDirectory(slashPos == std::string::npos ? std::string() : full_path.substr(0, slashPos + 1));
ParseFile(full_path, mpIOHandler);
mpIOHandler->PopDirectory();
}