For PR351:\
authorReid Spencer <rspencer@reidspencer.com>
Mon, 13 Dec 2004 02:57:53 +0000 (02:57 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Mon, 13 Dec 2004 02:57:53 +0000 (02:57 +0000)
* Consolidate path retrieval into just two methods. \
* Add FindLibrary as a convenience function. \
* Add isDynamicLibrary for testing for dynamic libs. \
* Make toString constant and reference clean.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18847 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/System/Path.h

index 90b61364b6def5404710b1e5ee3b42ae5d0ad1ed..7862e21998a6dd38202e9a254a4ba144ed9d0335 100644 (file)
@@ -88,32 +88,27 @@ namespace sys {
       /// directory.
       static Path GetTemporaryDirectory();
 
-      /// Determine the platform-specific location of a library by first
-      /// searching a list of library paths, then searching a list of "well
-      /// known" paths for the platform. T
-      /// @returns a valid Path object if the library was found, an invalid
-      /// one otherwise.
-      /// @throws nothing
-      /// @brief Locate a library in a platform specific manner.
-      static Path GetLibraryPath(const std::string& basename, 
-                                 const std::vector<std::string>& LibPaths);
-      /// 
-      /// Construct a path to the first system library directory. The
-      /// implementation of Path on a given platform must ensure that this
-      /// directory both exists and also contains standard system libraries
-      /// suitable for linking into programs.
+      /// Construct a vector of sys::Path that contains the "standard" system
+      /// library paths suitable for linking into programs. This function *must*
+      /// return the value of LLVM_LIB_SEARCH_PATH as the first item in \p Paths
+      /// if that environment variable is set and it references a directory.
       /// @throws nothing
       /// @brief Construct a path to the first system library directory
-      static Path GetSystemLibraryPath1();
-
-      /// Construct a path to the second system library directory. The
-      /// implementation of Path on a given platform must ensure that this
-      /// directory both exists and also contains standard system libraries
-      /// suitable for linking into programs. Note that the "second" system
-      /// library directory may or may not be different from the first. 
-      /// @throws nothing
-      /// @brief Construct a path to the second system library directory
-      static Path GetSystemLibraryPath2();
+      static void GetSystemLibraryPaths(std::vector<sys::Path>& Paths);
+
+      /// Construct a vector of sys::Path that contains the "standard" bytecode
+      /// library paths suitable for linking into an llvm program. This function
+      /// *must* return the value of LLVM_LIB_SEARCH_PATH as well as the values
+      /// of LLVM_LIBDIR and LLVMGCCDIR/bytecode-libs. It also must provide the
+      /// System library paths as returned by GetSystemLibraryPaths.
+      /// @brief Construct a list of directories in which bytecode could be
+      /// found.
+      static void GetBytecodeLibraryPaths(std::vector<sys::Path>& Paths);
+
+      /// Find the path to a library using its short name. Use the system
+      /// dependent library paths to locate the library.
+      /// @brief Find a library.
+      static Path  FindLibrary(std::string& short_name);
 
       /// Construct a path to the default LLVM configuration directory. The 
       /// implementation must ensure that this is a well-known (same on many
@@ -282,6 +277,15 @@ namespace sys {
       /// @brief Determine if the path references a bytecode file.
       bool isBytecodeFile() const;
 
+      /// This function determines if the path name in the object references a
+      /// native Dynamic Library (shared library, shared object) by looking at
+      /// the file's magic number. The Path object must reference a file, not a
+      /// directory. 
+      /// @return strue if the file starts with the magid number for a native
+      /// shared library.
+      /// @brief Determine if the path reference a dynamic library.
+      bool isDynamicLibrary() const;
+
       /// This function determines if the path name references an existing file
       /// or directory in the file system. Unlike isFile and isDirectory, this
       /// function actually checks for the existence of the file or directory.
@@ -322,7 +326,7 @@ namespace sys {
       /// by other software.
       /// @returns std::string containing the path name.
       /// @brief Returns the path as a std::string.
-      std::string toString() const { return path; }
+      const std::string& toString() const { return path; }
 
       /// This function returns the last component of the path name. If the
       /// isDirectory() function would return true then this returns the name