-
-//
-// Function: FileExists ()
-//
-// Description:
-// Determine if the specified filename exists and is readable.
-//
-// Inputs:
-// FN - The name of the file.
-//
-// Outputs:
-// None.
-//
-// Return Value:
-// TRUE - The file exists and is readable.
-// FALSE - The file does not exist or is unreadable.
-//
-static inline bool FileExists(const std::string &FN) {
- return access(FN.c_str(), R_OK | F_OK) != -1;
-}
-
-//
-// Function: IsArchive ()
-//
-// Description:
-// Determine if the specified file is an ar archive. It determines this by
-// checking the magic string at the beginning of the file.
-//
-// Inputs:
-// filename - A C++ string containing the name of the file.
-//
-// Outputs:
-// None.
-//
-// Return value:
-// TRUE - The file is an archive.
-// FALSE - The file is not an archive.
-//
-static inline bool IsArchive(const std::string &filename)
-{
- std::string ArchiveMagic("!<arch>\012");
- char buf[1 + ArchiveMagic.size()];
- std::ifstream f(filename.c_str());
- f.read(buf, ArchiveMagic.size());
- buf[ArchiveMagic.size()] = '\0';
- return ArchiveMagic == buf;
-}
-
-//
-// Function: FindLib ()
-//
-// Description:
-// This function locates a particular library. It will prepend and append
-// various directories, prefixes, and suffixes until it can find the library.
-//
-// Inputs:
-// Filename - Name of the file to find.
-// Paths - List of directories to search.
-//
-// Outputs:
-// None.
-//
-// Return value:
-// The name of the file is returned.
-// If the file is not found, an empty string is returned.
-//
-static std::string
-FindLib(const std::string &Filename, const std::vector<std::string> &Paths)
-{
+using namespace llvm;
+
+/// FindLib - Try to convert Filename into the name of a file that we can open,
+/// if it does not already name a file we can open, by first trying to open
+/// Filename, then libFilename.[suffix] for each of a set of several common
+/// library suffixes, in each of the directories in Paths and the directory
+/// named by the value of the environment variable LLVM_LIB_SEARCH_PATH. Returns
+/// an empty string if no matching file can be found.
+///
+std::string llvm::FindLib(const std::string &Filename,
+ const std::vector<std::string> &Paths,
+ bool SharedObjectOnly) {