| 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 <errno.h> | 7 #include <errno.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <sys/stat.h> | 10 #include <sys/stat.h> |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 | 504 |
| 505 if (flags & FLAG_DELETE_ON_CLOSE) | 505 if (flags & FLAG_DELETE_ON_CLOSE) |
| 506 unlink(path.value().c_str()); | 506 unlink(path.value().c_str()); |
| 507 | 507 |
| 508 async_ = ((flags & FLAG_ASYNC) == FLAG_ASYNC); | 508 async_ = ((flags & FLAG_ASYNC) == FLAG_ASYNC); |
| 509 error_details_ = FILE_OK; | 509 error_details_ = FILE_OK; |
| 510 file_.reset(descriptor); | 510 file_.reset(descriptor); |
| 511 } | 511 } |
| 512 #endif // !defined(OS_NACL) | 512 #endif // !defined(OS_NACL) |
| 513 | 513 |
| 514 bool File::DoFlush() { | 514 bool File::Flush() { |
| 515 ThreadRestrictions::AssertIOAllowed(); | 515 ThreadRestrictions::AssertIOAllowed(); |
| 516 DCHECK(IsValid()); | 516 DCHECK(IsValid()); |
| 517 SCOPED_FILE_TRACE("Flush"); |
| 517 | 518 |
| 518 #if defined(OS_NACL) | 519 #if defined(OS_NACL) |
| 519 NOTIMPLEMENTED(); // NaCl doesn't implement fsync. | 520 NOTIMPLEMENTED(); // NaCl doesn't implement fsync. |
| 520 return true; | 521 return true; |
| 521 #elif defined(OS_LINUX) || defined(OS_ANDROID) | 522 #elif defined(OS_LINUX) || defined(OS_ANDROID) |
| 522 return !HANDLE_EINTR(fdatasync(file_.get())); | 523 return !HANDLE_EINTR(fdatasync(file_.get())); |
| 523 #else | 524 #else |
| 524 return !HANDLE_EINTR(fsync(file_.get())); | 525 return !HANDLE_EINTR(fsync(file_.get())); |
| 525 #endif | 526 #endif |
| 526 } | 527 } |
| 527 | 528 |
| 528 void File::SetPlatformFile(PlatformFile file) { | 529 void File::SetPlatformFile(PlatformFile file) { |
| 529 DCHECK(!file_.is_valid()); | 530 DCHECK(!file_.is_valid()); |
| 530 file_.reset(file); | 531 file_.reset(file); |
| 531 } | 532 } |
| 532 | 533 |
| 533 } // namespace base | 534 } // namespace base |
| OLD | NEW |