summaryrefslogtreecommitdiffstats
path: root/base/include/android-base
diff options
context:
space:
mode:
authorMark Salyzyn <salyzyn@google.com>2018-11-13 13:38:33 -0800
committerMark Salyzyn <salyzyn@google.com>2018-11-14 12:54:08 -0800
commitd2f58888949645a9b08cd1b8954bc32b8145c6a8 (patch)
treea4349ce6b46e3987bb8900ec54d3283407244524 /base/include/android-base
parent46c2df581244c37b21638862059ae7468fa391fd (diff)
downloadsystem_core-d2f58888949645a9b08cd1b8954bc32b8145c6a8.tar.gz
system_core-d2f58888949645a9b08cd1b8954bc32b8145c6a8.tar.bz2
system_core-d2f58888949645a9b08cd1b8954bc32b8145c6a8.zip
base: TemporaryDir add DoNotRemove() method
Recursively delete all contents in a temporary directory in the destructor. If the caller wants the contents preserved, then call DoNotRemove(). Test: compile Bug: 119313545 Change-Id: I3601c06334920055a60dd3074b249824f4d6f510
Diffstat (limited to 'base/include/android-base')
-rw-r--r--base/include/android-base/file.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/base/include/android-base/file.h b/base/include/android-base/file.h
index 80d71346d..f8748b5d4 100644
--- a/base/include/android-base/file.h
+++ b/base/include/android-base/file.h
@@ -61,12 +61,16 @@ class TemporaryDir {
public:
TemporaryDir();
~TemporaryDir();
+ // Don't remove the temporary dir in the destructor.
+ void DoNotRemove() { remove_dir_and_contents_ = false; }
char path[1024];
private:
bool init(const std::string& tmp_dir);
+ bool remove_dir_and_contents_ = true;
+
DISALLOW_COPY_AND_ASSIGN(TemporaryDir);
};