From 1958d840491d3ed6f706ea9b9eb3029331b75d8e Mon Sep 17 00:00:00 2001
From: Wenqing Wang <wenqing.wang@ufz.de>
Date: Wed, 9 Sep 2015 15:47:41 +0200
Subject: [PATCH] Erase vtk filename extension from the base name.

---
 FileIO/MPI_IO/NodePartitionedMeshReader.cpp | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/FileIO/MPI_IO/NodePartitionedMeshReader.cpp b/FileIO/MPI_IO/NodePartitionedMeshReader.cpp
index 3e27ac50c4f..f2cae210d2d 100644
--- a/FileIO/MPI_IO/NodePartitionedMeshReader.cpp
+++ b/FileIO/MPI_IO/NodePartitionedMeshReader.cpp
@@ -15,6 +15,7 @@
 #include "NodePartitionedMeshReader.h"
 
 #include <logog/include/logog.hpp>
+#include <boost/algorithm/string/erase.hpp>
 
 #include "BaseLib/FileTools.h"
 #include "BaseLib/RunTime.h"
@@ -71,21 +72,25 @@ MeshLib::NodePartitionedMesh* NodePartitionedMeshReader::read(
 
     MeshLib::NodePartitionedMesh* mesh = nullptr;
 
+    /// Prefix of the filename of the partitioned mesh files.
+    std::string filename_prefix = file_name_base;
+    boost::erase_last(filename_prefix, ".vtk");
+
     // Always try binary file first
-    std::string const fname_new = file_name_base + "_partitioned_msh_cfg" +
+    std::string const fname_new = filename_prefix + "_partitioned_msh_cfg" +
         std::to_string(_mpi_comm_size) + ".bin";
 
     if(!BaseLib::IsFileExisting(fname_new)) // doesn't exist binary file.
     {
         INFO("-->Reading ASCII mesh file ...");
 
-        mesh = readASCII(file_name_base);
+        mesh = readASCII(filename_prefix);
     }
     else
     {
         INFO("-->Reading binary mesh file ...");
 
-        mesh = readBinary(file_name_base);
+        mesh = readBinary(filename_prefix);
     }
 
     INFO("\t\n>>Total elapsed time in reading mesh:%f s\n", timer.elapsed());
-- 
GitLab