| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <windows.h> | 5 #include <windows.h> |
| 6 | 6 |
| 7 #include <fstream> | 7 #include <fstream> |
| 8 #include <iostream> | 8 #include <iostream> |
| 9 | 9 |
| 10 #include "base/base_paths.h" | 10 #include "base/base_paths.h" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 // Simple function to dump some text into a new file. | 54 // Simple function to dump some text into a new file. |
| 55 void CreateTextFile(const std::wstring& filename, | 55 void CreateTextFile(const std::wstring& filename, |
| 56 const std::wstring& contents) { | 56 const std::wstring& contents) { |
| 57 std::ofstream file; | 57 std::ofstream file; |
| 58 file.open(filename.c_str()); | 58 file.open(filename.c_str()); |
| 59 ASSERT_TRUE(file.is_open()); | 59 ASSERT_TRUE(file.is_open()); |
| 60 file << contents; | 60 file << contents; |
| 61 file.close(); | 61 file.close(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 bool IsFileInUse(std::wstring path) { | 64 bool IsFileInUse(const std::wstring& path) { |
| 65 if (!file_util::PathExists(path)) | 65 if (!file_util::PathExists(path)) |
| 66 return false; | 66 return false; |
| 67 | 67 |
| 68 HANDLE handle = ::CreateFile(path.c_str(), FILE_ALL_ACCESS, | 68 HANDLE handle = ::CreateFile(path.c_str(), FILE_ALL_ACCESS, |
| 69 NULL, NULL, OPEN_EXISTING, NULL, NULL); | 69 NULL, NULL, OPEN_EXISTING, NULL, NULL); |
| 70 if (handle == INVALID_HANDLE_VALUE) | 70 if (handle == INVALID_HANDLE_VALUE) |
| 71 return true; | 71 return true; |
| 72 | 72 |
| 73 CloseHandle(handle); | 73 CloseHandle(handle); |
| 74 return false; | 74 return false; |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 LOG(INFO) << "compare " << file_name_from_1 << " and " << file_name_to_1; | 687 LOG(INFO) << "compare " << file_name_from_1 << " and " << file_name_to_1; |
| 688 EXPECT_TRUE(file_util::ContentsEqual(file_name_from_1, file_name_to_1)); | 688 EXPECT_TRUE(file_util::ContentsEqual(file_name_from_1, file_name_to_1)); |
| 689 | 689 |
| 690 std::wstring file_name_to_2(dir_name_to); | 690 std::wstring file_name_to_2(dir_name_to); |
| 691 file_util::AppendToPath(&file_name_to_2, L"2"); | 691 file_util::AppendToPath(&file_name_to_2, L"2"); |
| 692 file_util::AppendToPath(&file_name_to_2, L"File_2.txt"); | 692 file_util::AppendToPath(&file_name_to_2, L"File_2.txt"); |
| 693 EXPECT_TRUE(file_util::PathExists(file_name_to_2)); | 693 EXPECT_TRUE(file_util::PathExists(file_name_to_2)); |
| 694 LOG(INFO) << "compare " << file_name_from_2 << " and " << file_name_to_2; | 694 LOG(INFO) << "compare " << file_name_from_2 << " and " << file_name_to_2; |
| 695 EXPECT_TRUE(file_util::ContentsEqual(file_name_from_2, file_name_to_2)); | 695 EXPECT_TRUE(file_util::ContentsEqual(file_name_from_2, file_name_to_2)); |
| 696 } | 696 } |
| OLD | NEW |