From 69cce815e7414ad9a186920c78890c852986d6bf Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Thu, 29 Mar 2007 16:43:20 +0000 Subject: For PR789: * Add a method: bool isAbsolute() const, which determines if the path name is absolute or not. * Implement caching of file status information in the Path object. Allow it to be updated forcefully or lazily re-fetched from the cached value. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35456 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/System/Path.h | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'include/llvm') diff --git a/include/llvm/System/Path.h b/include/llvm/System/Path.h index f6b2be0..8192dc4 100644 --- a/include/llvm/System/Path.h +++ b/include/llvm/System/Path.h @@ -123,7 +123,7 @@ namespace sys { /// 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); + 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 @@ -162,14 +162,14 @@ namespace sys { /// provided so that they can be used to indicate null or error results in /// other lib/System functionality. /// @brief Construct an empty (and invalid) path. - Path() : path() {} + Path() : path(), status(0) {} /// This constructor will accept a std::string as a path. No checking is /// done on this path to determine if it is valid. To determine validity /// of the path, use the isValid method. /// @param p The path to assign. /// @brief Construct a Path from a string. - explicit Path(const std::string& p) : path(p) {} + explicit Path(const std::string& p) : path(p), status(0) {} /// @} /// @name Operators @@ -265,6 +265,11 @@ namespace sys { /// @brief Determines if the path references the root directory. bool isRootDirectory() const; + /// This function determines if the path name is absolute, as opposed to + /// relative. + /// @breif Determine if the path is absolute. + bool isAbsolute() const; + /// This function opens the file associated with the path name provided by /// the Path object and reads its magic number. If the magic number at the /// start of the file matches \p magic, true is returned. In all other @@ -352,7 +357,11 @@ namespace sys { /// of the file system. This returns false on success, or true on error /// and fills in the specified error string if specified. /// @brief Get file status. - bool getFileStatus(FileStatus &Status, std::string *Error = 0) const; + bool getFileStatus( + FileStatus &Status, ///< The resulting file status + bool forceUpdate = false, ///< Force an update from the file system + std::string *Error = 0 ///< Optional place to return an error msg. + ) const; /// @} /// @name Path Mutators @@ -511,6 +520,7 @@ namespace sys { /// @{ private: mutable std::string path; ///< Storage for the path name. + mutable FileStatus *status; ///< Status information. /// @} }; -- cgit v1.1