summaryrefslogtreecommitdiffstats
path: root/net/disk_cache/cache_util_posix.cc
diff options
context:
space:
mode:
Diffstat (limited to 'net/disk_cache/cache_util_posix.cc')
-rw-r--r--net/disk_cache/cache_util_posix.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/net/disk_cache/cache_util_posix.cc b/net/disk_cache/cache_util_posix.cc
index b33c560..2b13d9e 100644
--- a/net/disk_cache/cache_util_posix.cc
+++ b/net/disk_cache/cache_util_posix.cc
@@ -39,6 +39,26 @@ bool MoveCache(const base::FilePath& from_path, const base::FilePath& to_path) {
#endif
}
+void DeleteCache(const base::FilePath& path, bool remove_folder) {
+ base::FileEnumerator iter(path,
+ /* recursive */ false,
+ base::FileEnumerator::FILES);
+ for (base::FilePath file = iter.Next(); !file.value().empty();
+ file = iter.Next()) {
+ if (!base::DeleteFile(file, /* recursive */ false)) {
+ LOG(WARNING) << "Unable to delete cache.";
+ return;
+ }
+ }
+
+ if (remove_folder) {
+ if (!base::DeleteFile(path, /* recursive */ false)) {
+ LOG(WARNING) << "Unable to delete cache folder.";
+ return;
+ }
+ }
+}
+
bool DeleteCacheFile(const base::FilePath& name) {
return base::DeleteFile(name, false);
}