]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
access name of file after opening
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 3 May 2005 19:23:41 +0000 (19:23 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 3 May 2005 19:23:41 +0000 (19:23 +0000)
git-svn-id: https://svn.dealii.org/trunk@10634 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/include/base/path_search.h
deal.II/base/source/path_search.cc

index eb4274e90d6689844299e9ae91ab2900d764e95e..9d946f93f8d1f3a41b58b40ba79242081b70a2ee 100644 (file)
@@ -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<std::string>& 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<std::ifstream> 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 <class STREAM>
+inline
 void
 PathSearch::show(STREAM& out) const
 {
index 88b6ecba8d97da38ca4f5d7e4909f813cec07f3a..cc16f1a9b810f4b825ec9ee62be8723c6e1d42d3 100644 (file)
@@ -81,7 +81,6 @@ std::istream&
 PathSearch::open (const std::string& filename,
                  const std::string& suffix)
 {
-  std::string name;
   std::vector<std::string>::const_iterator path;
   const std::vector<std::string>::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<std::string>::const_iterator suffix;
   std::vector<std::string>::const_iterator path;
   const std::vector<std::string>::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;
            }
        }

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.