From: guido Date: Tue, 3 May 2005 19:23:41 +0000 (+0000) Subject: access name of file after opening X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=da1f6cf43bb5ccff4ba49ed4adb479da5c177531;p=dealii-svn.git access name of file after opening git-svn-id: https://svn.dealii.org/trunk@10634 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/base/include/base/path_search.h b/deal.II/base/include/base/path_search.h index eb4274e90d..9d946f93f8 100644 --- a/deal.II/base/include/base/path_search.h +++ b/deal.II/base/include/base/path_search.h @@ -118,6 +118,14 @@ class PathSearch std::istream& open(const std::string& filename, const std::string& suffix); + /** + * Return the actual name of the + * file opened by the previous + * call to one of the open() + * functions. + */ + const std::string& name() const; + /** * Show the paths and suffixes * used for this object. @@ -189,7 +197,7 @@ class PathSearch static std::vector& get_suffix_list(const std::string& cls); /** - * The flie class handled by this object. + * The file class handled by this object. */ const std::string cls; @@ -220,6 +228,12 @@ class PathSearch */ std::auto_ptr stream; + /** + * The actual name of the file + * that was opened previously. + */ + std::string real_name; + /** * Debug flag. No output if zero. */ @@ -232,7 +246,17 @@ class PathSearch }; +inline +const std::string& +PathSearch::name () const +{ + return real_name; +} + + + template +inline void PathSearch::show(STREAM& out) const { diff --git a/deal.II/base/source/path_search.cc b/deal.II/base/source/path_search.cc index 88b6ecba8d..cc16f1a9b8 100644 --- a/deal.II/base/source/path_search.cc +++ b/deal.II/base/source/path_search.cc @@ -81,7 +81,6 @@ std::istream& PathSearch::open (const std::string& filename, const std::string& suffix) { - std::string name; std::vector::const_iterator path; const std::vector::const_iterator endp = my_path_list.end(); @@ -93,16 +92,16 @@ PathSearch::open (const std::string& filename, // Try without suffix first for (path = my_path_list.begin(); path != endp; ++path) { - name = *path + filename; + real_name = *path + filename; if (debug > 1) deallog << "PathSearch[" << cls << "] trying " - << name << std::endl; - stream.reset(new std::ifstream(name.c_str())); + << real_name << std::endl; + stream.reset(new std::ifstream(real_name.c_str())); if (stream->is_open()) { if (debug > 0) deallog << "PathSearch[" << cls << "] opened " - << name << std::endl; + << real_name << std::endl; return *stream; } } @@ -110,16 +109,16 @@ PathSearch::open (const std::string& filename, // Now try with given suffix for (path = my_path_list.begin(); path != endp; ++path) { - name = *path + filename + suffix; + real_name = *path + filename + suffix; if (debug > 1) deallog << "PathSearch[" << cls << "] trying " - << name << std::endl; - stream.reset(new std::ifstream(name.c_str())); + << real_name << std::endl; + stream.reset(new std::ifstream(real_name.c_str())); if (stream->is_open()) { if (debug > 0) deallog << "PathSearch[" << cls << "] opened " - << name << std::endl; + << real_name << std::endl; return *stream; } } @@ -131,7 +130,6 @@ PathSearch::open (const std::string& filename, std::istream& PathSearch::open (const std::string& filename) { - std::string name; std::vector::const_iterator suffix; std::vector::const_iterator path; const std::vector::const_iterator ends = my_suffix_list.end(); @@ -147,16 +145,16 @@ PathSearch::open (const std::string& filename) { for (path = my_path_list.begin(); path != endp; ++path) { - name = *path + filename + *suffix; + real_name = *path + filename + *suffix; if (debug > 1) deallog << "PathSearch[" << cls << "] trying " - << name << std::endl; - stream.reset(new std::ifstream(name.c_str())); + << real_name << std::endl; + stream.reset(new std::ifstream(real_name.c_str())); if (stream->is_open()) { if (debug > 0) deallog << "PathSearch[" << cls << "] opened " - << name << std::endl; + << real_name << std::endl; return *stream; } }