Commit 294c383c authored by Brian Panneton's avatar Brian Panneton

BUG: Fixed resolving file names with protocol added

The bug appears when trying to use a filename given as:
file:///path/to/xmf/file.xmf and the xmf contains a reference to an h5 file.

- When writing you will end up with a file called 'file:' which contains
random data.
- When reading, libxml2 has no problem opening the xml file however
getRealPath() returns the wrong path for the h5 file. If you try to
use file.xmf from the to directory (ie: read("to/xmf/file.xmf")) the
h5 file will be loaded from 'to/file.h5'.

To correct the issue, we strip out the unwanted scheme and other stuff
in the URI and just use the path. (libxml has functions for this)
parent 4fe61475
......@@ -21,6 +21,7 @@
/* */
/*****************************************************************************/
#include <libxml/uri.h>
#include <limits.h>
#include <stdlib.h>
#include "XdmfSystemUtils.hpp"
......@@ -36,7 +37,13 @@ XdmfSystemUtils::~XdmfSystemUtils()
std::string
XdmfSystemUtils::getRealPath(const std::string & path)
{
xmlURIPtr ref = NULL;
ref = xmlCreateURI();
xmlParseURIReference(ref, path.c_str());
char realPath[PATH_MAX];
realpath(path.c_str(), realPath);
realpath(ref->path, realPath);
xmlFreeURI(ref);
return realPath;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment