| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 (last_separator != std::wstring::npos && last_dot < last_separator)) { | 70 (last_separator != std::wstring::npos && last_dot < last_separator)) { |
| 71 // The path looks something like "C:\pics.old\jojo" or "C:\pics\jojo". | 71 // The path looks something like "C:\pics.old\jojo" or "C:\pics\jojo". |
| 72 // We should just append the suffix to the entire path. | 72 // We should just append the suffix to the entire path. |
| 73 value.append(suffix); | 73 value.append(suffix); |
| 74 return; | 74 return; |
| 75 } | 75 } |
| 76 | 76 |
| 77 value.insert(last_dot, suffix); | 77 value.insert(last_dot, suffix); |
| 78 } | 78 } |
| 79 | 79 |
| 80 bool Move(const FilePath& from_path, const FilePath& to_path) { |
| 81 if (from_path.ReferencesParent() || to_path.ReferencesParent()) |
| 82 return false; |
| 83 return MoveUnsafe(from_path, to_path); |
| 84 } |
| 85 |
| 86 bool CopyFile(const FilePath& from_path, const FilePath& to_path) { |
| 87 if (from_path.ReferencesParent() || to_path.ReferencesParent()) |
| 88 return false; |
| 89 return CopyFileUnsafe(from_path, to_path); |
| 90 } |
| 91 |
| 80 bool ContentsEqual(const FilePath& filename1, const FilePath& filename2) { | 92 bool ContentsEqual(const FilePath& filename1, const FilePath& filename2) { |
| 81 // We open the file in binary format even if they are text files because | 93 // We open the file in binary format even if they are text files because |
| 82 // we are just comparing that bytes are exactly same in both files and not | 94 // we are just comparing that bytes are exactly same in both files and not |
| 83 // doing anything smart with text formatting. | 95 // doing anything smart with text formatting. |
| 84 std::ifstream file1(filename1.value().c_str(), | 96 std::ifstream file1(filename1.value().c_str(), |
| 85 std::ios::in | std::ios::binary); | 97 std::ios::in | std::ios::binary); |
| 86 std::ifstream file2(filename2.value().c_str(), | 98 std::ifstream file2(filename2.value().c_str(), |
| 87 std::ios::in | std::ios::binary); | 99 std::ios::in | std::ios::binary); |
| 88 | 100 |
| 89 // Even if both files aren't openable (and thus, in some sense, "equal"), | 101 // Even if both files aren't openable (and thus, in some sense, "equal"), |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 // FileEnumerator | 402 // FileEnumerator |
| 391 // | 403 // |
| 392 // Note: the main logic is in file_util_<platform>.cc | 404 // Note: the main logic is in file_util_<platform>.cc |
| 393 | 405 |
| 394 bool FileEnumerator::ShouldSkip(const FilePath& path) { | 406 bool FileEnumerator::ShouldSkip(const FilePath& path) { |
| 395 FilePath::StringType basename = path.BaseName().value(); | 407 FilePath::StringType basename = path.BaseName().value(); |
| 396 return IsDot(path) || (IsDotDot(path) && !(INCLUDE_DOT_DOT & file_type_)); | 408 return IsDot(path) || (IsDotDot(path) && !(INCLUDE_DOT_DOT & file_type_)); |
| 397 } | 409 } |
| 398 | 410 |
| 399 } // namespace | 411 } // namespace |
| OLD | NEW |