aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/System/Path.h
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2007-03-29 19:05:44 +0000
committerReid Spencer <rspencer@reidspencer.com>2007-03-29 19:05:44 +0000
commit8475ec068c213d0bf73f7686d82491a8f12e3b32 (patch)
treeb455b532bbe4b9a50f4baadecf4a48d83fc801a6 /include/llvm/System/Path.h
parentf735f7b3ac424bd701af2da2e3d4b69fbcb2b203 (diff)
For PR789:
Make the sys::Path::getFileStatus function more efficient by having it return a pointer to the FileStatus structure rather than copy it. Adjust uses of the function accordingly. Also, fix some memory issues in sys::Path. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35476 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/System/Path.h')
-rw-r--r--include/llvm/System/Path.h24
1 files changed, 15 insertions, 9 deletions
diff --git a/include/llvm/System/Path.h b/include/llvm/System/Path.h
index 8d2f39107d..84e6942cd4 100644
--- a/include/llvm/System/Path.h
+++ b/include/llvm/System/Path.h
@@ -166,6 +166,7 @@ namespace sys {
/// @brief Construct an empty (and invalid) path.
Path() : path(), status(0) {}
~Path() { delete status; }
+ Path(const Path &that) : path(that.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
@@ -183,6 +184,9 @@ namespace sys {
/// @brief Assignment Operator
Path &operator=(const Path &that) {
path = that.path;
+ if (status)
+ delete status;
+ status = 0;
return *this;
}
@@ -223,9 +227,11 @@ namespace sys {
/// @brief Determine if a path is syntactically valid or not.
bool isValid() const;
- /// This function determines if the contents of the path name are
- /// empty. That is, the path has a zero length. This does NOT determine if
- /// if the file is empty. Use the getSize method for that.
+ /// This function determines if the contents of the path name are empty.
+ /// That is, the path name has a zero length. This does NOT determine if
+ /// if the file is empty. To get the length of the file itself, Use the
+ /// getFileStatus() method and then the getSize() on the returned
+ /// FileStatus object
/// @returns true iff the path is empty.
/// @brief Determines if the path name is empty (invalid).
bool isEmpty() const { return path.empty(); }
@@ -357,13 +363,13 @@ namespace sys {
/// This function returns status information about the file. The type of
/// path (file or directory) is updated to reflect the actual contents
- /// of the file system. This returns false on success, or true on error
- /// and fills in the specified error string if specified.
+ /// of the file system.
+ /// @returns 0 on failure, with Error explaining why (if non-zero)
+ /// @returns a pointer to a FileStatus structure on success.
/// @brief Get file status.
- 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 FileStatus *getFileStatus(
+ bool forceUpdate = false, ///< Force an update from the file system
+ std::string *Error = 0 ///< Optional place to return an error msg.
) const;
/// @}