OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/drive/file_cache.h" | 5 #include "chrome/browser/chromeos/drive/file_cache.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 // deleted. | 103 // deleted. |
104 void DeleteFilesSelectively(const base::FilePath& path_to_delete_pattern, | 104 void DeleteFilesSelectively(const base::FilePath& path_to_delete_pattern, |
105 const base::FilePath& path_to_keep) { | 105 const base::FilePath& path_to_keep) { |
106 // Enumerate all files in directory of |path_to_delete_pattern| that match | 106 // Enumerate all files in directory of |path_to_delete_pattern| that match |
107 // base name of |path_to_delete_pattern|. | 107 // base name of |path_to_delete_pattern|. |
108 // If a file is not |path_to_keep|, delete it. | 108 // If a file is not |path_to_keep|, delete it. |
109 bool success = true; | 109 bool success = true; |
110 file_util::FileEnumerator enumerator( | 110 file_util::FileEnumerator enumerator( |
111 path_to_delete_pattern.DirName(), | 111 path_to_delete_pattern.DirName(), |
112 false, // not recursive | 112 false, // not recursive |
113 file_util::FileEnumerator::FILES | | 113 file_util::FileEnumerator::FILES, |
114 file_util::FileEnumerator::SHOW_SYM_LINKS, | |
115 path_to_delete_pattern.BaseName().value()); | 114 path_to_delete_pattern.BaseName().value()); |
116 for (base::FilePath current = enumerator.Next(); !current.empty(); | 115 for (base::FilePath current = enumerator.Next(); !current.empty(); |
117 current = enumerator.Next()) { | 116 current = enumerator.Next()) { |
118 // If |path_to_keep| is not empty and same as current, don't delete it. | 117 // If |path_to_keep| is not empty and same as current, don't delete it. |
119 if (!path_to_keep.empty() && current == path_to_keep) | 118 if (!path_to_keep.empty() && current == path_to_keep) |
120 continue; | 119 continue; |
121 | 120 |
122 success = file_util::Delete(current, false); | 121 success = file_util::Delete(current, false); |
123 if (!success) | 122 if (!success) |
124 DVLOG(1) << "Error deleting " << current.value(); | 123 DVLOG(1) << "Error deleting " << current.value(); |
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1117 } | 1116 } |
1118 | 1117 |
1119 // static | 1118 // static |
1120 FileCache::CacheSubDirectoryType FileCache::GetSubDirectoryType( | 1119 FileCache::CacheSubDirectoryType FileCache::GetSubDirectoryType( |
1121 const FileCacheEntry& cache_entry) { | 1120 const FileCacheEntry& cache_entry) { |
1122 return cache_entry.is_persistent() ? CACHE_TYPE_PERSISTENT : CACHE_TYPE_TMP; | 1121 return cache_entry.is_persistent() ? CACHE_TYPE_PERSISTENT : CACHE_TYPE_TMP; |
1123 } | 1122 } |
1124 | 1123 |
1125 } // namespace internal | 1124 } // namespace internal |
1126 } // namespace drive | 1125 } // namespace drive |
OLD | NEW |