summaryrefslogtreecommitdiffstats
path: root/Source/cmWorkingDirectory.h
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-03-09 12:43:39 (GMT)
committerKitware Robot <kwrobot@kitware.com>2018-03-09 12:43:54 (GMT)
commite11410bb0c66152c6fafb56d40c9328abaa7a1ab (patch)
tree14113116753b98ab5b0932ab87c3092756d6f295 /Source/cmWorkingDirectory.h
parent44fc5729637330e463666f97ba952dcb6f2e9506 (diff)
parent5901699672cce82d9622a02c4c7d22889029ee0c (diff)
downloadCMake-e11410bb0c66152c6fafb56d40c9328abaa7a1ab.zip
CMake-e11410bb0c66152c6fafb56d40c9328abaa7a1ab.tar.gz
CMake-e11410bb0c66152c6fafb56d40c9328abaa7a1ab.tar.bz2
Merge topic 'cmWorkingDirectory_success_checking'
5901699672 cmDepends: Remove attempt to change directory that always fails e60e4dfc88 cmWorkingDirectory: Check success of current dir changes e654622aee Tests: Add --build-and-test test case a865f0beb2 Tests: Confirm test working dir set successfully Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !1817
Diffstat (limited to 'Source/cmWorkingDirectory.h')
-rw-r--r--Source/cmWorkingDirectory.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/Source/cmWorkingDirectory.h b/Source/cmWorkingDirectory.h
index aff9267..1f18ce7 100644
--- a/Source/cmWorkingDirectory.h
+++ b/Source/cmWorkingDirectory.h
@@ -9,6 +9,12 @@
/** \class cmWorkingDirectory
* \brief An RAII class to manipulate the working directory.
+ *
+ * The current working directory is set to the location given to the
+ * constructor. The working directory can be changed again as needed
+ * by calling SetDirectory(). When the object is destroyed, the destructor
+ * will restore the working directory to what it was when the object was
+ * created, regardless of any calls to SetDirectory() in the meantime.
*/
class cmWorkingDirectory
{
@@ -16,10 +22,21 @@ public:
cmWorkingDirectory(std::string const& newdir);
~cmWorkingDirectory();
+ bool SetDirectory(std::string const& newdir);
void Pop();
+ bool Failed() const { return ResultCode != 0; }
+
+ /** \return 0 if the last attempt to set the working directory was
+ * successful. If it failed, the value returned will be the
+ * \c errno value associated with the failure. A description
+ * of the error code can be obtained by passing the result
+ * to \c std::strerror().
+ */
+ int GetLastResult() const { return ResultCode; }
private:
std::string OldDir;
+ int ResultCode;
};
#endif