OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/disk_cache/cache_util.h" | 5 #include "net/disk_cache/cache_util.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 std::wstring current(adjusted_path); | 32 std::wstring current(adjusted_path); |
33 current += data.cFileName; | 33 current += data.cFileName; |
34 DeleteFile(current.c_str()); | 34 DeleteFile(current.c_str()); |
35 } while (FindNextFile(handle, &data)); | 35 } while (FindNextFile(handle, &data)); |
36 } | 36 } |
37 | 37 |
38 } // namespace | 38 } // namespace |
39 | 39 |
40 namespace disk_cache { | 40 namespace disk_cache { |
41 | 41 |
42 bool MoveCache(const std::wstring& from_path, const std::wstring& to_path) { | 42 bool MoveCache(const FilePath& from_path, const FilePath& to_path) { |
43 // I don't want to use the shell version of move because if something goes | 43 // I don't want to use the shell version of move because if something goes |
44 // wrong, that version will attempt to move file by file and fail at the end. | 44 // wrong, that version will attempt to move file by file and fail at the end. |
45 if (!MoveFileEx(from_path.c_str(), to_path.c_str(), 0)) { | 45 if (!MoveFileEx(from_path.value().c_str(), to_path.value().c_str(), 0)) { |
46 LOG(ERROR) << "Unable to move the cache: " << GetLastError(); | 46 LOG(ERROR) << "Unable to move the cache: " << GetLastError(); |
47 return false; | 47 return false; |
48 } | 48 } |
49 return true; | 49 return true; |
50 } | 50 } |
51 | 51 |
| 52 void DeleteCache(const FilePath& path, bool remove_folder) { |
| 53 DeleteFiles(path.value().c_str(), L"*"); |
| 54 if (remove_folder) |
| 55 RemoveDirectory(path.value().c_str()); |
| 56 } |
| 57 |
| 58 bool DeleteCacheFile(const FilePath& name) { |
| 59 // We do a simple delete, without ever falling back to SHFileOperation, as the |
| 60 // version from base does. |
| 61 return DeleteFile(name.value().c_str()) ? true : false; |
| 62 } |
| 63 |
52 void DeleteCache(const std::wstring& path, bool remove_folder) { | 64 void DeleteCache(const std::wstring& path, bool remove_folder) { |
53 DeleteFiles(path.c_str(), L"*"); | 65 DeleteCache(FilePath::FromWStringHack(path), remove_folder); |
54 if (remove_folder) | |
55 RemoveDirectory(path.c_str()); | |
56 } | 66 } |
57 | 67 |
58 bool DeleteCacheFile(const std::wstring& name) { | 68 bool DeleteCacheFile(const std::wstring& name) { |
59 // We do a simple delete, without ever falling back to SHFileOperation, as the | 69 return DeleteCacheFile(FilePath::FromWStringHack(name)); |
60 // version from base does. | |
61 return DeleteFile(name.c_str()) ? true : false; | |
62 } | 70 } |
63 | 71 |
64 } // namespace disk_cache | 72 } // namespace disk_cache |
OLD | NEW |