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/files/file.h" | 5 #include "base/files/file.h" |
6 | 6 |
7 #include <io.h> | 7 #include <io.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 &other_handle, | 263 &other_handle, |
264 0, // dwDesiredAccess ignored due to SAME_ACCESS | 264 0, // dwDesiredAccess ignored due to SAME_ACCESS |
265 FALSE, // !bInheritHandle | 265 FALSE, // !bInheritHandle |
266 DUPLICATE_SAME_ACCESS)) { | 266 DUPLICATE_SAME_ACCESS)) { |
267 return File(OSErrorToFileError(GetLastError())); | 267 return File(OSErrorToFileError(GetLastError())); |
268 } | 268 } |
269 | 269 |
270 File other(other_handle); | 270 File other(other_handle); |
271 if (async()) | 271 if (async()) |
272 other.async_ = true; | 272 other.async_ = true; |
273 return other.Pass(); | 273 return other; |
274 } | 274 } |
275 | 275 |
276 // Static. | 276 // Static. |
277 File::Error File::OSErrorToFileError(DWORD last_error) { | 277 File::Error File::OSErrorToFileError(DWORD last_error) { |
278 switch (last_error) { | 278 switch (last_error) { |
279 case ERROR_SHARING_VIOLATION: | 279 case ERROR_SHARING_VIOLATION: |
280 return FILE_ERROR_IN_USE; | 280 return FILE_ERROR_IN_USE; |
281 case ERROR_FILE_EXISTS: | 281 case ERROR_FILE_EXISTS: |
282 return FILE_ERROR_EXISTS; | 282 return FILE_ERROR_EXISTS; |
283 case ERROR_FILE_NOT_FOUND: | 283 case ERROR_FILE_NOT_FOUND: |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 ThreadRestrictions::AssertIOAllowed(); | 400 ThreadRestrictions::AssertIOAllowed(); |
401 DCHECK(IsValid()); | 401 DCHECK(IsValid()); |
402 return ::FlushFileBuffers(file_.Get()) != FALSE; | 402 return ::FlushFileBuffers(file_.Get()) != FALSE; |
403 } | 403 } |
404 | 404 |
405 void File::SetPlatformFile(PlatformFile file) { | 405 void File::SetPlatformFile(PlatformFile file) { |
406 file_.Set(file); | 406 file_.Set(file); |
407 } | 407 } |
408 | 408 |
409 } // namespace base | 409 } // namespace base |
OLD | NEW |