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.
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;
*/
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.
*/
};
+inline
+const std::string&
+PathSearch::name () const
+{
+ return real_name;
+}
+
+
+
template <class STREAM>
+inline
void
PathSearch::show(STREAM& out) const
{
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();
// 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;
}
}
// 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;
}
}
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();
{
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;
}
}