1*a9fa9459Szrj // dirsearch.h -- directory searching for gold -*- C++ -*- 2*a9fa9459Szrj 3*a9fa9459Szrj // Copyright (C) 2006-2016 Free Software Foundation, Inc. 4*a9fa9459Szrj // Written by Ian Lance Taylor <iant@google.com>. 5*a9fa9459Szrj 6*a9fa9459Szrj // This file is part of gold. 7*a9fa9459Szrj 8*a9fa9459Szrj // This program is free software; you can redistribute it and/or modify 9*a9fa9459Szrj // it under the terms of the GNU General Public License as published by 10*a9fa9459Szrj // the Free Software Foundation; either version 3 of the License, or 11*a9fa9459Szrj // (at your option) any later version. 12*a9fa9459Szrj 13*a9fa9459Szrj // This program is distributed in the hope that it will be useful, 14*a9fa9459Szrj // but WITHOUT ANY WARRANTY; without even the implied warranty of 15*a9fa9459Szrj // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16*a9fa9459Szrj // GNU General Public License for more details. 17*a9fa9459Szrj 18*a9fa9459Szrj // You should have received a copy of the GNU General Public License 19*a9fa9459Szrj // along with this program; if not, write to the Free Software 20*a9fa9459Szrj // Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, 21*a9fa9459Szrj // MA 02110-1301, USA. 22*a9fa9459Szrj 23*a9fa9459Szrj #ifndef GOLD_DIRSEARCH_H 24*a9fa9459Szrj #define GOLD_DIRSEARCH_H 25*a9fa9459Szrj 26*a9fa9459Szrj #include <string> 27*a9fa9459Szrj #include <list> 28*a9fa9459Szrj 29*a9fa9459Szrj #include "options.h" 30*a9fa9459Szrj #include "token.h" 31*a9fa9459Szrj 32*a9fa9459Szrj namespace gold 33*a9fa9459Szrj { 34*a9fa9459Szrj 35*a9fa9459Szrj class General_options; 36*a9fa9459Szrj class Workqueue; 37*a9fa9459Szrj 38*a9fa9459Szrj // A simple interface to manage directories to be searched for 39*a9fa9459Szrj // libraries. 40*a9fa9459Szrj 41*a9fa9459Szrj class Dirsearch 42*a9fa9459Szrj { 43*a9fa9459Szrj public: Dirsearch()44*a9fa9459Szrj Dirsearch() 45*a9fa9459Szrj : directories_(NULL), token_(true) 46*a9fa9459Szrj { } 47*a9fa9459Szrj 48*a9fa9459Szrj // Set the list of directories to search. 49*a9fa9459Szrj void 50*a9fa9459Szrj initialize(Workqueue*, const General_options::Dir_list*); 51*a9fa9459Szrj 52*a9fa9459Szrj // Search for a file, giving one or two names to search for (the 53*a9fa9459Szrj // second one may be empty). Return a full path name for the file, 54*a9fa9459Szrj // or the empty string if it could not be found. This may only be 55*a9fa9459Szrj // called if the token is not blocked. Set *IS_IN_SYSROOT if the 56*a9fa9459Szrj // file was found in a directory which is in the sysroot. *PINDEX 57*a9fa9459Szrj // should be set to zero the first time this is called; it will be 58*a9fa9459Szrj // updated with the index of the directory where the file is found, 59*a9fa9459Szrj // and that value plus one may be used to find the next file with 60*a9fa9459Szrj // the same name(s). 61*a9fa9459Szrj std::string 62*a9fa9459Szrj find(const std::vector<std::string>& names, bool* is_in_sysroot, 63*a9fa9459Szrj int* pindex, std::string *found_name) const; 64*a9fa9459Szrj 65*a9fa9459Szrj // Return the blocker token which controls access. 66*a9fa9459Szrj Task_token* token()67*a9fa9459Szrj token() 68*a9fa9459Szrj { return &this->token_; } 69*a9fa9459Szrj 70*a9fa9459Szrj // Search for a file in a directory list. This is a low-level function and 71*a9fa9459Szrj // therefore can be used before options and parameters are set. 72*a9fa9459Szrj static std::string 73*a9fa9459Szrj find_file_in_dir_list(const std::string& name, 74*a9fa9459Szrj const General_options::Dir_list& directories, 75*a9fa9459Szrj const std::string& extra_search_dir); 76*a9fa9459Szrj 77*a9fa9459Szrj private: 78*a9fa9459Szrj // We can not copy this class. 79*a9fa9459Szrj Dirsearch(const Dirsearch&); 80*a9fa9459Szrj Dirsearch& operator=(const Dirsearch&); 81*a9fa9459Szrj 82*a9fa9459Szrj // Directories to search. 83*a9fa9459Szrj const General_options::Dir_list* directories_; 84*a9fa9459Szrj // Blocker token to control access from tasks. 85*a9fa9459Szrj Task_token token_; 86*a9fa9459Szrj }; 87*a9fa9459Szrj 88*a9fa9459Szrj } // End namespace gold. 89*a9fa9459Szrj 90*a9fa9459Szrj #endif // !defined(GOLD_DIRSEARCH_H) 91