summaryrefslogtreecommitdiffstats
path: root/Source/cmWorkingDirectory.h
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@crascit.com>2018-03-04 06:27:09 (GMT)
committerCraig Scott <craig.scott@crascit.com>2018-03-08 09:07:14 (GMT)
commite60e4dfc88252aaec53f0d832508d41dff6165fd (patch)
tree5903e9e8f2eb57780d47a21d83f282f9cee11741 /Source/cmWorkingDirectory.h
parente654622aee22655c418a9c663fad79243ca0c819 (diff)
downloadCMake-e60e4dfc88252aaec53f0d832508d41dff6165fd.zip
CMake-e60e4dfc88252aaec53f0d832508d41dff6165fd.tar.gz
CMake-e60e4dfc88252aaec53f0d832508d41dff6165fd.tar.bz2
cmWorkingDirectory: Check success of current dir changes
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