summaryrefslogtreecommitdiffstats
path: root/net/disk_cache/cache_util_win.cc
diff options
context:
space:
mode:
Diffstat (limited to 'net/disk_cache/cache_util_win.cc')
-rw-r--r--net/disk_cache/cache_util_win.cc29
1 files changed, 29 insertions, 0 deletions
diff --git a/net/disk_cache/cache_util_win.cc b/net/disk_cache/cache_util_win.cc
index 3337511..8c54b91 100644
--- a/net/disk_cache/cache_util_win.cc
+++ b/net/disk_cache/cache_util_win.cc
@@ -11,6 +11,29 @@
#include "base/message_loop.h"
#include "base/win/scoped_handle.h"
+namespace {
+
+// Deletes all the files on path that match search_name pattern.
+void DeleteFiles(const base::FilePath& path, const wchar_t* search_name) {
+ base::FilePath name(path.Append(search_name));
+
+ WIN32_FIND_DATA data;
+ HANDLE handle = FindFirstFile(name.value().c_str(), &data);
+ if (handle == INVALID_HANDLE_VALUE)
+ return;
+
+ do {
+ if (data.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY ||
+ data.dwFileAttributes == FILE_ATTRIBUTE_REPARSE_POINT)
+ continue;
+ DeleteFile(path.Append(data.cFileName).value().c_str());
+ } while (FindNextFile(handle, &data));
+
+ FindClose(handle);
+}
+
+} // namespace
+
namespace disk_cache {
bool MoveCache(const base::FilePath& from_path, const base::FilePath& to_path) {
@@ -23,6 +46,12 @@ bool MoveCache(const base::FilePath& from_path, const base::FilePath& to_path) {
return true;
}
+void DeleteCache(const base::FilePath& path, bool remove_folder) {
+ DeleteFiles(path, L"*");
+ if (remove_folder)
+ RemoveDirectory(path.value().c_str());
+}
+
bool DeleteCacheFile(const base::FilePath& name) {
// We do a simple delete, without ever falling back to SHFileOperation, as the
// version from base does.