Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 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/test_file_util.h" | 5 #include "base/test_file_util.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 77 | 77 |
| 78 // If this is false, then we just processed the last portion of the file. | 78 // If this is false, then we just processed the last portion of the file. |
| 79 if (!file_is_page_aligned) | 79 if (!file_is_page_aligned) |
| 80 break; | 80 break; |
| 81 } | 81 } |
| 82 | 82 |
| 83 if (!file_is_page_aligned) { | 83 if (!file_is_page_aligned) { |
| 84 // The size of the file isn't a multiple of the page size, so we'll have | 84 // The size of the file isn't a multiple of the page size, so we'll have |
| 85 // to open the file again, this time without the FILE_FLAG_NO_BUFFERING | 85 // to open the file again, this time without the FILE_FLAG_NO_BUFFERING |
| 86 // flag and use SetEndOfFile to mark EOF. | 86 // flag and use SetEndOfFile to mark EOF. |
| 87 file_handle.Set(NULL); | |
| 87 file_handle.Set(CreateFile(file, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, | 88 file_handle.Set(CreateFile(file, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, |
|
darin (slow to review)
2008/12/08 18:18:44
maybe the smart pointer class should be made smart
tommi (sloooow) - chröme
2008/12/09 10:07:45
in this case I think it was just the engineer that
| |
| 88 0, NULL)); | 89 0, NULL)); |
| 89 CHECK(SetFilePointer(file_handle, total_bytes, NULL, FILE_BEGIN) != | 90 CHECK(SetFilePointer(file_handle, total_bytes, NULL, FILE_BEGIN) != |
| 90 INVALID_SET_FILE_POINTER); | 91 INVALID_SET_FILE_POINTER); |
| 91 CHECK(::SetEndOfFile(file_handle)); | 92 CHECK(::SetEndOfFile(file_handle)); |
| 92 } | 93 } |
| 93 | 94 |
| 94 // Restore the file attributes. | 95 // Restore the file attributes. |
| 95 CHECK(::SetFileTime(file_handle, &bhi.ftCreationTime, &bhi.ftLastAccessTime, | 96 CHECK(::SetFileTime(file_handle, &bhi.ftCreationTime, &bhi.ftLastAccessTime, |
| 96 &bhi.ftLastWriteTime)); | 97 &bhi.ftLastWriteTime)); |
| 97 | 98 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 149 EvictFileFromSystemCache(cur_dest_path.c_str()); | 150 EvictFileFromSystemCache(cur_dest_path.c_str()); |
| 150 } | 151 } |
| 151 } while (FindNextFile(fh, &fd)); | 152 } while (FindNextFile(fh, &fd)); |
| 152 | 153 |
| 153 FindClose(fh); | 154 FindClose(fh); |
| 154 return true; | 155 return true; |
| 155 } | 156 } |
| 156 | 157 |
| 157 } // namespace file_util | 158 } // namespace file_util |
| 158 | 159 |
| OLD | NEW |