| 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/test/test_file_util.h" | 5 #include "base/test/test_file_util.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <aclapi.h> | 8 #include <aclapi.h> |
| 9 #include <shlwapi.h> | 9 #include <shlwapi.h> |
| 10 | 10 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 // WriteFile will fail if we provide a buffer size that isn't a | 168 // WriteFile will fail if we provide a buffer size that isn't a |
| 169 // sector multiple, so we'll have to write the entire buffer with | 169 // sector multiple, so we'll have to write the entire buffer with |
| 170 // padded zeros and then use SetEndOfFile to truncate the file. | 170 // padded zeros and then use SetEndOfFile to truncate the file. |
| 171 ZeroMemory(buffer + bytes_read, kOneMB - bytes_read); | 171 ZeroMemory(buffer + bytes_read, kOneMB - bytes_read); |
| 172 file_is_aligned = false; | 172 file_is_aligned = false; |
| 173 } | 173 } |
| 174 | 174 |
| 175 // Move back to the position we just read from. | 175 // Move back to the position we just read from. |
| 176 // Note that SetFilePointer will also fail if total_bytes isn't sector | 176 // Note that SetFilePointer will also fail if total_bytes isn't sector |
| 177 // aligned, but that shouldn't happen here. | 177 // aligned, but that shouldn't happen here. |
| 178 DCHECK((total_bytes % kOneMB) == 0); | 178 DCHECK_EQ(total_bytes % kOneMB, 0); |
| 179 SetFilePointer(file_handle.Get(), total_bytes, NULL, FILE_BEGIN); | 179 SetFilePointer(file_handle.Get(), total_bytes, NULL, FILE_BEGIN); |
| 180 if (!::WriteFile(file_handle.Get(), buffer, kOneMB, &bytes_written, NULL) || | 180 if (!::WriteFile(file_handle.Get(), buffer, kOneMB, &bytes_written, NULL) || |
| 181 bytes_written != kOneMB) { | 181 bytes_written != kOneMB) { |
| 182 BOOL freed = VirtualFree(buffer, 0, MEM_RELEASE); | 182 BOOL freed = VirtualFree(buffer, 0, MEM_RELEASE); |
| 183 DCHECK(freed); | 183 DCHECK(freed); |
| 184 NOTREACHED(); | 184 NOTREACHED(); |
| 185 return false; | 185 return false; |
| 186 } | 186 } |
| 187 | 187 |
| 188 total_bytes += bytes_read; | 188 total_bytes += bytes_read; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 DCHECK(info_ != NULL); | 273 DCHECK(info_ != NULL); |
| 274 DCHECK_NE(0u, length_); | 274 DCHECK_NE(0u, length_); |
| 275 } | 275 } |
| 276 | 276 |
| 277 FilePermissionRestorer::~FilePermissionRestorer() { | 277 FilePermissionRestorer::~FilePermissionRestorer() { |
| 278 if (!RestorePermissionInfo(path_, info_, length_)) | 278 if (!RestorePermissionInfo(path_, info_, length_)) |
| 279 NOTREACHED(); | 279 NOTREACHED(); |
| 280 } | 280 } |
| 281 | 281 |
| 282 } // namespace base | 282 } // namespace base |
| OLD | NEW |