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/gdata/gdata_cache.h" | 5 #include "chrome/browser/chromeos/gdata/gdata_cache.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/chromeos/chromeos_version.h" | 9 #include "base/chromeos/chromeos_version.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
175 // deleted. | 175 // deleted. |
176 void DeleteFilesSelectively(const FilePath& path_to_delete_pattern, | 176 void DeleteFilesSelectively(const FilePath& path_to_delete_pattern, |
177 const FilePath& path_to_keep) { | 177 const FilePath& path_to_keep) { |
178 // Enumerate all files in directory of |path_to_delete_pattern| that match | 178 // Enumerate all files in directory of |path_to_delete_pattern| that match |
179 // base name of |path_to_delete_pattern|. | 179 // base name of |path_to_delete_pattern|. |
180 // If a file is not |path_to_keep|, delete it. | 180 // If a file is not |path_to_keep|, delete it. |
181 bool success = true; | 181 bool success = true; |
182 file_util::FileEnumerator enumerator( | 182 file_util::FileEnumerator enumerator( |
183 path_to_delete_pattern.DirName(), | 183 path_to_delete_pattern.DirName(), |
184 false, // not recursive | 184 false, // not recursive |
185 static_cast<file_util::FileEnumerator::FileType>( | 185 (file_util::FileEnumerator::FILES | |
186 file_util::FileEnumerator::FILES | | 186 file_util::FileEnumerator::SHOW_SYM_LINKS), |
jar (doing other things)
2012/08/06 18:27:02
nit: IMO, no need for paren around arg.
Haruki Sato
2012/08/06 23:22:18
I think it helps when the expression occupies mult
jar (doing other things)
2012/08/07 01:47:43
These examples are IMO borderline... but they prov
| |
187 file_util::FileEnumerator::SHOW_SYM_LINKS), | |
188 path_to_delete_pattern.BaseName().value()); | 187 path_to_delete_pattern.BaseName().value()); |
189 for (FilePath current = enumerator.Next(); !current.empty(); | 188 for (FilePath current = enumerator.Next(); !current.empty(); |
190 current = enumerator.Next()) { | 189 current = enumerator.Next()) { |
191 // If |path_to_keep| is not empty and same as current, don't delete it. | 190 // If |path_to_keep| is not empty and same as current, don't delete it. |
192 if (!path_to_keep.empty() && current == path_to_keep) | 191 if (!path_to_keep.empty() && current == path_to_keep) |
193 continue; | 192 continue; |
194 | 193 |
195 success = file_util::Delete(current, false); | 194 success = file_util::Delete(current, false); |
196 if (!success) | 195 if (!success) |
197 DVLOG(1) << "Error deleting " << current.value(); | 196 DVLOG(1) << "Error deleting " << current.value(); |
(...skipping 1375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1573 const GDataCacheEntry& cache_entry) { | 1572 const GDataCacheEntry& cache_entry) { |
1574 return cache_entry.is_persistent() ? CACHE_TYPE_PERSISTENT : CACHE_TYPE_TMP; | 1573 return cache_entry.is_persistent() ? CACHE_TYPE_PERSISTENT : CACHE_TYPE_TMP; |
1575 } | 1574 } |
1576 | 1575 |
1577 void SetFreeDiskSpaceGetterForTesting(FreeDiskSpaceGetterInterface* getter) { | 1576 void SetFreeDiskSpaceGetterForTesting(FreeDiskSpaceGetterInterface* getter) { |
1578 delete global_free_disk_getter_for_testing; // Safe to delete NULL; | 1577 delete global_free_disk_getter_for_testing; // Safe to delete NULL; |
1579 global_free_disk_getter_for_testing = getter; | 1578 global_free_disk_getter_for_testing = getter; |
1580 } | 1579 } |
1581 | 1580 |
1582 } // namespace gdata | 1581 } // namespace gdata |
OLD | NEW |