]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Search first for the file with its complete given name. I.e., if someone
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 7 Oct 2013 13:28:39 +0000 (13:28 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 7 Oct 2013 13:28:39 +0000 (13:28 +0000)
searches for <mesh.vtk> with additional suffix <.vtk>, then still find the
file if it exists before trying <mesh.vtk.vtk>.

git-svn-id: https://svn.dealii.org/trunk@31162 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/source/base/path_search.cc

index 6d3e0a5eef0f2e44ef70a7a220f02fbd7e391679..4f0faa9b8cc303c29fff85c1b557a5b0ed9be657 100644 (file)
@@ -124,22 +124,44 @@ PathSearch::find (const std::string &filename,
             << my_path_list.size() << " directories "
             << std::endl;
 
-  // Try to open file
+  // Try to open file in the various directories we have
   for (path = my_path_list.begin(); path != endp; ++path)
     {
-      real_name = *path + filename + suffix;
-      if (debug > 1)
-        deallog << "PathSearch[" << cls << "] trying "
-                << real_name << std::endl;
-      FILE *fp = fopen(real_name.c_str(), open_mode);
-      if (fp != 0)
-        {
-          if (debug > 0)
-            deallog << "PathSearch[" << cls << "] opened "
-                    << real_name << std::endl;
-          fclose(fp);
-          return real_name;
-        }
+      // see if the file exists as given, i.e., with
+      // the whole filename specified, including (possibly)
+      // the suffix
+      {
+       real_name = *path + filename;
+       if (debug > 1)
+         deallog << "PathSearch[" << cls << "] trying "
+                 << real_name << std::endl;
+       FILE *fp = fopen(real_name.c_str(), open_mode);
+       if (fp != 0)
+         {
+           if (debug > 0)
+             deallog << "PathSearch[" << cls << "] opened "
+                     << real_name << std::endl;
+           fclose(fp);
+           return real_name;
+         }
+      }
+
+      // try again with the suffix appended
+      {
+       real_name = *path + filename + suffix;
+       if (debug > 1)
+         deallog << "PathSearch[" << cls << "] trying "
+                 << real_name << std::endl;
+       FILE *fp = fopen(real_name.c_str(), open_mode);
+       if (fp != 0)
+         {
+           if (debug > 0)
+             deallog << "PathSearch[" << cls << "] opened "
+                     << real_name << std::endl;
+           fclose(fp);
+           return real_name;
+         }
+      }
     }
   AssertThrow(false, ExcFileNotFound(filename, cls));
   return std::string("");

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.