-/** Find a file.
- It will search in the current dir, in the construction-arg, and
- in any other added path, in this order.
-
- @return
- The full path if found, or empty string if not found
- */
-String
-File_path::find (String nm) const
+ /* Handle absolute file name. */
+ File_name file_name (name);
+ if (file_name.dir_[0] == DIRSEP && is_file (file_name.to_string ()))
+ return file_name.to_string ();
+
+ for (vsize i = 0; i < dirs_.size (); i++)
+ {
+ 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 "";
+}
+
+/*
+ Try to find
+
+ file.EXT,
+
+ where EXT is from EXTENSIONS.
+*/
+string
+File_path::find (string name, char const *extensions[])