- String path = elem (i);
- String sep = to_string (DIRSEP);
- String right (path.right_string (1));
- if (path.length () && right != sep)
- path += to_string (DIRSEP);
-
- path += nm;
-
-
-#if 0
- /*
- Check if directory. TODO: encapsulate for autoconf
- */
- struct stat sbuf;
- if (stat (path.to_str0 (), &sbuf) != 0)
- continue;
-
- if (! (sbuf.st_mode & __S_IFREG))
- continue;
-#endif
-#if !STAT_MACROS_BROKEN
-
- struct stat sbuf;
- if (stat (path.to_str0 (), &sbuf) != 0)
- continue;
+ File_name file_name (name);
+ File_name dir = (string) dirs_[i];
+ file_name.root_ = dir.root_;
+ dir.root_ = "";
+ if (file_name.dir_.empty ())
+ file_name.dir_ = dir.to_string ();
+ else if (!dir.to_string ().empty ())
+ file_name.dir_ = dir.to_string ()
+ + ::to_string (DIRSEP) + file_name.dir_;
+ if (is_file (file_name.to_string ()))
+ return file_name.to_string ();
+ }
+ return "";
+}