| 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 "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 | 10 |
| 11 namespace disk_cache { | 11 namespace disk_cache { |
| 12 | 12 |
| 13 bool MoveCache(const std::wstring& from_path, const std::wstring& to_path) { | 13 bool MoveCache(const FilePath& from_path, const FilePath& to_path) { |
| 14 // Just use the version from base. | 14 // Just use the version from base. |
| 15 return file_util::Move(from_path.c_str(), to_path.c_str()); | 15 return file_util::Move(from_path, to_path); |
| 16 } | 16 } |
| 17 | 17 |
| 18 void DeleteCache(const std::wstring& path, bool remove_folder) { | 18 void DeleteCache(const FilePath& path, bool remove_folder) { |
| 19 file_util::FileEnumerator iter(FilePath::FromWStringHack(path), | 19 file_util::FileEnumerator iter(path, |
| 20 /* recursive */ false, | 20 /* recursive */ false, |
| 21 file_util::FileEnumerator::FILES); | 21 file_util::FileEnumerator::FILES); |
| 22 for (FilePath file = iter.Next(); !file.value().empty(); file = iter.Next()) { | 22 for (FilePath file = iter.Next(); !file.value().empty(); file = iter.Next()) { |
| 23 if (!file_util::Delete(file, /* recursive */ false)) | 23 if (!file_util::Delete(file, /* recursive */ false)) |
| 24 NOTREACHED(); | 24 NOTREACHED(); |
| 25 } | 25 } |
| 26 | 26 |
| 27 if (remove_folder) { | 27 if (remove_folder) { |
| 28 if (!file_util::Delete(path, /* recursive */ false)) | 28 if (!file_util::Delete(path, /* recursive */ false)) |
| 29 NOTREACHED(); | 29 NOTREACHED(); |
| 30 } | 30 } |
| 31 } | 31 } |
| 32 | 32 |
| 33 bool DeleteCacheFile(const std::wstring& name) { | 33 bool DeleteCacheFile(const FilePath& name) { |
| 34 return file_util::Delete(name, false); | 34 return file_util::Delete(name, false); |
| 35 } | 35 } |
| 36 | 36 |
| 37 void DeleteCache(const std::wstring& path, bool remove_folder) { |
| 38 DeleteCache(FilePath::FromWStringHack(path), remove_folder); |
| 39 } |
| 40 |
| 41 bool DeleteCacheFile(const std::wstring& name) { |
| 42 return DeleteCacheFile(FilePath::FromWStringHack(name)); |
| 43 } |
| 44 |
| 37 } // namespace disk_cache | 45 } // namespace disk_cache |
| OLD | NEW |