commit | 464ea6114353a18b4cb5fc2c70f8553f5ba9dc2e | [log] [tgz] |
---|---|---|
author | Yabin Cui <yabinc@google.com> | Wed Dec 06 14:20:07 2017 -0800 |
committer | Yabin Cui <yabinc@google.com> | Wed Dec 06 14:20:07 2017 -0800 |
tree | 8fd13062f2b2f820e4754c7756e8afa44a461704 | |
parent | 3946d93023264cc24e706231ef786d9fa820cb4f [diff] |
base: allow creating tempfile in a custom temporary dir. Bug: http://b/70232908 Test: none. Change-Id: I24b894793f6725186b3582a91db083427e51aa5a
diff --git a/base/include/android-base/test_utils.h b/base/include/android-base/test_utils.h index 07a5edd..4cfa06b 100644 --- a/base/include/android-base/test_utils.h +++ b/base/include/android-base/test_utils.h
@@ -24,6 +24,7 @@ class TemporaryFile { public: TemporaryFile(); + explicit TemporaryFile(const std::string& tmp_dir); ~TemporaryFile(); // Release the ownership of fd, caller is reponsible for closing the
diff --git a/base/test_utils.cpp b/base/test_utils.cpp index 1cfa9e6..9d8dfb2 100644 --- a/base/test_utils.cpp +++ b/base/test_utils.cpp
@@ -84,6 +84,10 @@ init(GetSystemTempDir()); } +TemporaryFile::TemporaryFile(const std::string& tmp_dir) { + init(tmp_dir); +} + TemporaryFile::~TemporaryFile() { if (fd != -1) { close(fd);