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 "base/file_util.h" | 5 #include "base/file_util.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <io.h> | 8 #include <io.h> |
9 #endif | 9 #endif |
10 #include <stdio.h> | 10 #include <stdio.h> |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 const FilePath& path, | 271 const FilePath& path, |
272 const FilePath::StringType& suffix) { | 272 const FilePath::StringType& suffix) { |
273 bool have_suffix = !suffix.empty(); | 273 bool have_suffix = !suffix.empty(); |
274 if (!PathExists(path) && | 274 if (!PathExists(path) && |
275 (!have_suffix || !PathExists(FilePath(path.value() + suffix)))) { | 275 (!have_suffix || !PathExists(FilePath(path.value() + suffix)))) { |
276 return 0; | 276 return 0; |
277 } | 277 } |
278 | 278 |
279 FilePath new_path; | 279 FilePath new_path; |
280 for (int count = 1; count <= kMaxUniqueFiles; ++count) { | 280 for (int count = 1; count <= kMaxUniqueFiles; ++count) { |
281 new_path = path.InsertBeforeExtensionASCII(StringPrintf(" (%d)", count)); | 281 new_path = |
| 282 path.InsertBeforeExtensionASCII(base::StringPrintf(" (%d)", count)); |
282 if (!PathExists(new_path) && | 283 if (!PathExists(new_path) && |
283 (!have_suffix || !PathExists(FilePath(new_path.value() + suffix)))) { | 284 (!have_suffix || !PathExists(FilePath(new_path.value() + suffix)))) { |
284 return count; | 285 return count; |
285 } | 286 } |
286 } | 287 } |
287 | 288 |
288 return -1; | 289 return -1; |
289 } | 290 } |
290 | 291 |
291 bool ContainsPath(const FilePath &parent, const FilePath& child) { | 292 bool ContainsPath(const FilePath &parent, const FilePath& child) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 // FileEnumerator | 355 // FileEnumerator |
355 // | 356 // |
356 // Note: the main logic is in file_util_<platform>.cc | 357 // Note: the main logic is in file_util_<platform>.cc |
357 | 358 |
358 bool FileEnumerator::ShouldSkip(const FilePath& path) { | 359 bool FileEnumerator::ShouldSkip(const FilePath& path) { |
359 FilePath::StringType basename = path.BaseName().value(); | 360 FilePath::StringType basename = path.BaseName().value(); |
360 return IsDot(path) || (IsDotDot(path) && !(INCLUDE_DOT_DOT & file_type_)); | 361 return IsDot(path) || (IsDotDot(path) && !(INCLUDE_DOT_DOT & file_type_)); |
361 } | 362 } |
362 | 363 |
363 } // namespace | 364 } // namespace |
OLD | NEW |