From 20d6a12192e547472f1e38c80ad0a4ffd564f761 Mon Sep 17 00:00:00 2001 From: Christoph Wintersteiger Date: Fri, 29 Sep 2017 14:47:16 +0200 Subject: [PATCH 1/2] check extension of filename to ensure that the loading process is successful --- libsrc/meshing/meshclass.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/libsrc/meshing/meshclass.cpp b/libsrc/meshing/meshclass.cpp index 92094c80..2b3e9885 100644 --- a/libsrc/meshing/meshclass.cpp +++ b/libsrc/meshing/meshclass.cpp @@ -409,11 +409,16 @@ namespace netgen void Mesh :: Save (const string & filename) const { + ostream * outfile; + if (filename.substr(filename.length()-7,7) == ".vol.gz") + outfile = new ogzstream(filename.c_str()); + else if (filename.substr(filename.length()-4,4) == ".vol") + outfile = new ofstream(filename.c_str()); + else + outfile = new ogzstream((filename+".vol.gz").c_str()); - ofstream outfile(filename.c_str()); - // ogzstream outfile( (filename+".gz") .c_str()); - - Save(outfile); + Save(*outfile); + delete outfile; } From ccc092d2c5985145c5b0ab2e8569d4da407c4868 Mon Sep 17 00:00:00 2001 From: Christoph Wintersteiger Date: Mon, 30 Oct 2017 13:43:01 +0100 Subject: [PATCH 2/2] save check of file ending --- libsrc/meshing/meshclass.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libsrc/meshing/meshclass.cpp b/libsrc/meshing/meshclass.cpp index 2b3e9885..468d40df 100644 --- a/libsrc/meshing/meshclass.cpp +++ b/libsrc/meshing/meshclass.cpp @@ -410,9 +410,9 @@ namespace netgen void Mesh :: Save (const string & filename) const { ostream * outfile; - if (filename.substr(filename.length()-7,7) == ".vol.gz") + if (filename.find(".vol.gz")!=string::npos) outfile = new ogzstream(filename.c_str()); - else if (filename.substr(filename.length()-4,4) == ".vol") + else if (filename.find(".vol")!=string::npos) outfile = new ofstream(filename.c_str()); else outfile = new ogzstream((filename+".vol.gz").c_str());