| 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/platform_file.h" | 5 #include "base/platform_file.h" |
| 6 | 6 |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <errno.h> | 8 #include <errno.h> |
| 9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
| 10 #include <unistd.h> | 10 #include <unistd.h> |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 } | 110 } |
| 111 | 111 |
| 112 static PlatformFileError CallFctnlFlock(PlatformFile file, bool do_lock) { | 112 static PlatformFileError CallFctnlFlock(PlatformFile file, bool do_lock) { |
| 113 NOTIMPLEMENTED(); // NaCl doesn't implement flock struct. | 113 NOTIMPLEMENTED(); // NaCl doesn't implement flock struct. |
| 114 return PLATFORM_FILE_ERROR_INVALID_OPERATION; | 114 return PLATFORM_FILE_ERROR_INVALID_OPERATION; |
| 115 } | 115 } |
| 116 #endif // defined(OS_NACL) | 116 #endif // defined(OS_NACL) |
| 117 | 117 |
| 118 } // namespace | 118 } // namespace |
| 119 | 119 |
| 120 // NaCl doesn't implement system calls to open files directly. | |
| 121 #if !defined(OS_NACL) | |
| 122 FILE* FdopenPlatformFile(PlatformFile file, const char* mode) { | |
| 123 return fdopen(file, mode); | |
| 124 } | |
| 125 #endif // !defined(OS_NACL) | |
| 126 | |
| 127 bool ClosePlatformFile(PlatformFile file) { | 120 bool ClosePlatformFile(PlatformFile file) { |
| 128 base::ThreadRestrictions::AssertIOAllowed(); | 121 base::ThreadRestrictions::AssertIOAllowed(); |
| 129 return !IGNORE_EINTR(close(file)); | 122 return !IGNORE_EINTR(close(file)); |
| 130 } | 123 } |
| 131 | 124 |
| 132 int64 SeekPlatformFile(PlatformFile file, | 125 int64 SeekPlatformFile(PlatformFile file, |
| 133 PlatformFileWhence whence, | 126 PlatformFileWhence whence, |
| 134 int64 offset) { | 127 int64 offset) { |
| 135 base::ThreadRestrictions::AssertIOAllowed(); | 128 base::ThreadRestrictions::AssertIOAllowed(); |
| 136 if (file < 0 || offset < 0) | 129 if (file < 0 || offset < 0) |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 default: | 354 default: |
| 362 #if !defined(OS_NACL) // NaCl build has no metrics code. | 355 #if !defined(OS_NACL) // NaCl build has no metrics code. |
| 363 UMA_HISTOGRAM_SPARSE_SLOWLY("PlatformFile.UnknownErrors.Posix", | 356 UMA_HISTOGRAM_SPARSE_SLOWLY("PlatformFile.UnknownErrors.Posix", |
| 364 saved_errno); | 357 saved_errno); |
| 365 #endif | 358 #endif |
| 366 return PLATFORM_FILE_ERROR_FAILED; | 359 return PLATFORM_FILE_ERROR_FAILED; |
| 367 } | 360 } |
| 368 } | 361 } |
| 369 | 362 |
| 370 } // namespace base | 363 } // namespace base |
| OLD | NEW |