113468Skvn// dirsearch.h -- directory searching for gold -*- C++ -*- 213468Skvn 313468Skvn// Copyright 2006, 2007, 2008 Free Software Foundation, Inc. 413468Skvn// Written by Ian Lance Taylor <iant@google.com>. 513468Skvn 613468Skvn// This file is part of gold. 713468Skvn 813468Skvn// This program is free software; you can redistribute it and/or modify 913468Skvn// it under the terms of the GNU General Public License as published by 1013468Skvn// the Free Software Foundation; either version 3 of the License, or 1113468Skvn// (at your option) any later version. 1213468Skvn 1313468Skvn// This program is distributed in the hope that it will be useful, 1413468Skvn// but WITHOUT ANY WARRANTY; without even the implied warranty of 1513468Skvn// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1613468Skvn// GNU General Public License for more details. 1713468Skvn 1813468Skvn// You should have received a copy of the GNU General Public License 1913468Skvn// along with this program; if not, write to the Free Software 2013468Skvn// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, 2113468Skvn// MA 02110-1301, USA. 2213468Skvn 2313468Skvn#ifndef GOLD_DIRSEARCH_H 2413468Skvn#define GOLD_DIRSEARCH_H 2513468Skvn 2613468Skvn#include <string> 2713468Skvn#include <list> 2813468Skvn 2913468Skvn#include "options.h" 3013468Skvn#include "token.h" 3113468Skvn 3213468Skvnnamespace gold 3313468Skvn{ 3413468Skvn 3513468Skvnclass General_options; 3613468Skvnclass Workqueue; 3713468Skvn 3813468Skvn// A simple interface to manage directories to be searched for 3913468Skvn// libraries. 4013468Skvn 4113468Skvnclass Dirsearch 4213468Skvn{ 4313468Skvn public: 4413468Skvn Dirsearch() 4513468Skvn : directories_(NULL), token_(true) 4613468Skvn { } 4713468Skvn 4813468Skvn // Set the list of directories to search. 4913468Skvn void 5013468Skvn initialize(Workqueue*, const General_options::Dir_list*); 5113468Skvn 5213468Skvn // Search for a file, giving one or two names to search for (the 5313468Skvn // second one may be empty). Return a full path name for the file, 5413468Skvn // or the empty string if it could not be found. This may only be 5513468Skvn // called if the token is not blocked. Set *IS_IN_SYSROOT if the 5613468Skvn // file was found in a directory which is in the sysroot. *PINDEX 5713468Skvn // should be set to zero the first time this is called; it will be 5813468Skvn // updated with the index of the directory where the file is found, 5913468Skvn // and that value plus one may be used to find the next file with 6013468Skvn // the same name(s). 6113468Skvn std::string 6213468Skvn find(const std::string&, const std::string& n2, bool* is_in_sysroot, 6313468Skvn int* pindex) const; 6413468Skvn 6513468Skvn // Return the blocker token which controls access. 6613468Skvn Task_token* 6713468Skvn token() 6813468Skvn { return &this->token_; } 6913468Skvn 7013468Skvn private: 7113468Skvn // We can not copy this class. 7213468Skvn Dirsearch(const Dirsearch&); 7313468Skvn Dirsearch& operator=(const Dirsearch&); 7413468Skvn 7513468Skvn // Directories to search. 7613468Skvn const General_options::Dir_list* directories_; 7713468Skvn // Blocker token to control access from tasks. 7813468Skvn Task_token token_; 7913468Skvn}; 8013468Skvn 8113468Skvn} // End namespace gold. 8213468Skvn 8313468Skvn#endif // !defined(GOLD_DIRSEARCH_H) 8413468Skvn