Base: Add default tag manipulation
am: 3aa893647c -s ours
Change-Id: If6a78cb8cc3e0d54c2971c815f6599878badb01d
diff --git a/include/android-base/test_utils.h b/include/android-base/test_utils.h
index 2edafe3..b95fa07 100644
--- a/include/android-base/test_utils.h
+++ b/include/android-base/test_utils.h
@@ -31,6 +31,8 @@
// Release the ownership of fd, caller is reponsible for closing the
// fd or stream properly.
int release();
+ // Don't remove the temporary file in the destructor.
+ void DoNotRemove() { remove_file_ = false; }
int fd;
char path[1024];
@@ -38,6 +40,8 @@
private:
void init(const std::string& tmp_dir);
+ bool remove_file_ = true;
+
DISALLOW_COPY_AND_ASSIGN(TemporaryFile);
};
diff --git a/test_utils.cpp b/test_utils.cpp
index 9d8dfb2..1619c21 100644
--- a/test_utils.cpp
+++ b/test_utils.cpp
@@ -92,7 +92,9 @@
if (fd != -1) {
close(fd);
}
- unlink(path);
+ if (remove_file_) {
+ unlink(path);
+ }
}
int TemporaryFile::release() {