| 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 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 File::Error File::Lock() { | 363 File::Error File::Lock() { |
| 364 SCOPED_FILE_TRACE("Lock"); | 364 SCOPED_FILE_TRACE("Lock"); |
| 365 return CallFcntlFlock(file_.get(), true); | 365 return CallFcntlFlock(file_.get(), true); |
| 366 } | 366 } |
| 367 | 367 |
| 368 File::Error File::Unlock() { | 368 File::Error File::Unlock() { |
| 369 SCOPED_FILE_TRACE("Unlock"); | 369 SCOPED_FILE_TRACE("Unlock"); |
| 370 return CallFcntlFlock(file_.get(), false); | 370 return CallFcntlFlock(file_.get(), false); |
| 371 } | 371 } |
| 372 | 372 |
| 373 File File::Duplicate() { | 373 File File::Duplicate() const { |
| 374 if (!IsValid()) | 374 if (!IsValid()) |
| 375 return File(); | 375 return File(); |
| 376 | 376 |
| 377 SCOPED_FILE_TRACE("Duplicate"); | 377 SCOPED_FILE_TRACE("Duplicate"); |
| 378 | 378 |
| 379 PlatformFile other_fd = dup(GetPlatformFile()); | 379 PlatformFile other_fd = dup(GetPlatformFile()); |
| 380 if (other_fd == -1) | 380 if (other_fd == -1) |
| 381 return File(OSErrorToFileError(errno)); | 381 return File(OSErrorToFileError(errno)); |
| 382 | 382 |
| 383 File other(other_fd); | 383 File other(other_fd); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 return !HANDLE_EINTR(fsync(file_.get())); | 524 return !HANDLE_EINTR(fsync(file_.get())); |
| 525 #endif | 525 #endif |
| 526 } | 526 } |
| 527 | 527 |
| 528 void File::SetPlatformFile(PlatformFile file) { | 528 void File::SetPlatformFile(PlatformFile file) { |
| 529 DCHECK(!file_.is_valid()); | 529 DCHECK(!file_.is_valid()); |
| 530 file_.reset(file); | 530 file_.reset(file); |
| 531 } | 531 } |
| 532 | 532 |
| 533 } // namespace base | 533 } // namespace base |
| OLD | NEW |