Skip to content
Snippets Groups Projects
Commit ff93da45 authored by Christoph Lehmann's avatar Christoph Lehmann
Browse files

Changed handling of relative mesh paths in prj file

parent 24d62b40
No related branches found
No related tags found
No related merge requests found
...@@ -185,8 +185,19 @@ std::unique_ptr<MeshLib::Mesh> readSingleMesh( ...@@ -185,8 +185,19 @@ std::unique_ptr<MeshLib::Mesh> readSingleMesh(
mesh_file, true /* compute_element_neighbors */)); mesh_file, true /* compute_element_neighbors */));
if (!mesh) if (!mesh)
{ {
std::filesystem::path abspath{mesh_file};
try
{
abspath = std::filesystem::absolute(mesh_file);
}
catch (std::filesystem::filesystem_error const& e)
{
ERR("Determining the absolute path of '{}' failed: {}", mesh_file,
e.what());
}
OGS_FATAL("Could not read mesh from '{:s}' file. No mesh added.", OGS_FATAL("Could not read mesh from '{:s}' file. No mesh added.",
mesh_file); abspath.string());
} }
#ifdef DOXYGEN_DOCU_ONLY #ifdef DOXYGEN_DOCU_ONLY
......
...@@ -203,12 +203,7 @@ bool hasFileExtension(std::string const& extension, std::string const& filename) ...@@ -203,12 +203,7 @@ bool hasFileExtension(std::string const& extension, std::string const& filename)
std::string copyPathToFileName(const std::string& file_name, std::string copyPathToFileName(const std::string& file_name,
const std::string& source) const std::string& source)
{ {
auto filePath = std::filesystem::path(file_name); return (std::filesystem::path(source) / file_name).string();
if (filePath.has_parent_path())
{
return filePath.string();
}
return (std::filesystem::path(source) /= filePath).string();
} }
std::string extractPath(std::string const& pathname) std::string extractPath(std::string const& pathname)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment