OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "net/disk_cache/simple/simple_index_file.h" |
| 6 |
| 7 #include <string> |
| 8 |
| 9 #include "base/callback.h" |
| 10 #include "base/files/file_enumerator.h" |
| 11 #include "base/files/file_path.h" |
| 12 #include "base/files/file_util.h" |
| 13 |
| 14 namespace disk_cache { |
| 15 |
| 16 // static |
| 17 bool SimpleIndexFile::TraverseCacheDirectory( |
| 18 const std::string& cache_path, |
| 19 const EntryFileCallback& entry_file_callback) { |
| 20 const int kFileSuffixLength = sizeof("_0") - 1; |
| 21 const base::FilePath::StringType file_pattern = FILE_PATH_LITERAL("*_[0-2]"); |
| 22 base::FileEnumerator enumerator( |
| 23 base::FilePath(cache_path), false /* recursive */, |
| 24 base::FileEnumerator::FILES, file_pattern); |
| 25 for (base::FilePath file_path = enumerator.Next(); !file_path.empty(); |
| 26 file_path = enumerator.Next()) { |
| 27 entry_file_callback.Run(file_path.value().c_str()); |
| 28 } |
| 29 return true; |
| 30 } |
| 31 |
| 32 // static |
| 33 bool SimpleIndexFile::GetPlatformFileInfo(const char* path, |
| 34 base::PlatformFileInfo* info) { |
| 35 *info = file_util::GetFileInfo(base::FilePath(path)); |
| 36 return true; |
| 37 } |
| 38 |
| 39 } // namespace disk_cache |
OLD | NEW |