| 1 | // dirsearch.h -- directory searching for gold -*- C++ -*- |
| 2 | |
| 3 | #ifndef GOLD_DIRSEARCH_H |
| 4 | #define GOLD_DIRSEARCH_H |
| 5 | |
| 6 | #include <string> |
| 7 | #include <list> |
| 8 | |
| 9 | #include "workqueue.h" |
| 10 | |
| 11 | namespace gold |
| 12 | { |
| 13 | |
| 14 | class General_options; |
| 15 | |
| 16 | // A simple interface to manage directories to be searched for |
| 17 | // libraries. |
| 18 | |
| 19 | class Dirsearch |
| 20 | { |
| 21 | public: |
| 22 | Dirsearch(); |
| 23 | |
| 24 | // Add a directory to the search path. |
| 25 | void |
| 26 | add(Workqueue*, const char*); |
| 27 | |
| 28 | // Add a list of directories to the search path. |
| 29 | void |
| 30 | add(Workqueue*, const General_options::Dir_list&); |
| 31 | |
| 32 | // Search for a file, giving one or two names to search for (the |
| 33 | // second one may be empty). Return a full path name for the file, |
| 34 | // or the empty string if it could not be found. This may only be |
| 35 | // called if the token is not blocked. |
| 36 | std::string |
| 37 | find(const std::string&, const std::string& n2 = std::string()) const; |
| 38 | |
| 39 | // Return a reference to the blocker token which controls access. |
| 40 | const Task_token& |
| 41 | token() const |
| 42 | { return this->token_; } |
| 43 | |
| 44 | private: |
| 45 | // We can not copy this class. |
| 46 | Dirsearch(const Dirsearch&); |
| 47 | Dirsearch& operator=(const Dirsearch&); |
| 48 | |
| 49 | // Directories to search. |
| 50 | std::list<const char*> directories_; |
| 51 | // Blocker token to control access from tasks. |
| 52 | Task_token token_; |
| 53 | }; |
| 54 | |
| 55 | } // End namespace gold. |
| 56 | |
| 57 | #endif // !defined(GOLD_DIRSEARCH_H) |