From: bangerth Date: Mon, 7 Oct 2013 13:28:39 +0000 (+0000) Subject: Search first for the file with its complete given name. I.e., if someone X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=73ffe236853b05b8f2d0adc84c522259fc30590e;p=dealii-svn.git Search first for the file with its complete given name. I.e., if someone searches for with additional suffix <.vtk>, then still find the file if it exists before trying . git-svn-id: https://svn.dealii.org/trunk@31162 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/source/base/path_search.cc b/deal.II/source/base/path_search.cc index 6d3e0a5eef..4f0faa9b8c 100644 --- a/deal.II/source/base/path_search.cc +++ b/deal.II/source/base/path_search.cc @@ -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("");