summaryrefslogtreecommitdiff
path: root/src/mongo/unittest/temp_dir.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/unittest/temp_dir.h')
-rw-r--r--src/mongo/unittest/temp_dir.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/mongo/unittest/temp_dir.h b/src/mongo/unittest/temp_dir.h
index 561c7266195..711ac9c7f4c 100644
--- a/src/mongo/unittest/temp_dir.h
+++ b/src/mongo/unittest/temp_dir.h
@@ -30,6 +30,7 @@
#pragma once
#include <string>
+#include <utility>
namespace mongo {
@@ -63,14 +64,21 @@ public:
*/
~TempDir();
+ /**
+ * Release the path encapsulated by this TempDir to be cleaned up by the caller as necessary.
+ *
+ * A released TempDir is left with an empty path, and its destructor will perform no cleanup.
+ */
+ std::string release() noexcept {
+ return std::exchange(_path, {});
+ }
+
const std::string& path() const {
return _path;
}
/**
- * Set the path where TempDir() will create temporary directories. This is a workaround
- * for situations where you might want to log, but you've not yet run the MONGO_INITIALIZERs,
- * and should be removed if ever command line parsing is seperated from MONGO_INITIALIZERs.
+ * Set the path where TempDir() will create temporary directories.
*/
static void setTempPath(std::string tempPath);