| Index: base/platform_file_posix.cc
|
| diff --git a/base/platform_file_posix.cc b/base/platform_file_posix.cc
|
| index 9b42c7a184fea0d22ee060e1e3022c87325686c3..8023b82e36d7c3448d4cd2d62873b5650ee19d2a 100644
|
| --- a/base/platform_file_posix.cc
|
| +++ b/base/platform_file_posix.cc
|
| @@ -78,6 +78,9 @@ PlatformFile CreatePlatformFile(const FilePath& name, int flags,
|
| NOTREACHED();
|
| }
|
|
|
| + if (flags & PLATFORM_FILE_TERMINAL_DEVICE)
|
| + open_flags |= O_NOCTTY | O_NDELAY;
|
| +
|
| COMPILE_ASSERT(O_RDONLY == 0, O_RDONLY_must_equal_zero);
|
|
|
| int mode = S_IRUSR | S_IWUSR;
|
| @@ -175,6 +178,24 @@ int ReadPlatformFile(PlatformFile file, int64 offset, char* data, int size) {
|
| return bytes_read ? bytes_read : rv;
|
| }
|
|
|
| +int ReadPlatformFileFromCurrentPos(PlatformFile file, char* data, int size) {
|
| + base::ThreadRestrictions::AssertIOAllowed();
|
| + if (file < 0 || size < 0)
|
| + return -1;
|
| +
|
| + int bytes_read = 0;
|
| + int rv;
|
| + do {
|
| + rv = HANDLE_EINTR(read(file, data, size));
|
| + if (rv <= 0)
|
| + break;
|
| +
|
| + bytes_read += rv;
|
| + } while (bytes_read < size);
|
| +
|
| + return bytes_read ? bytes_read : rv;
|
| +}
|
| +
|
| int ReadPlatformFileNoBestEffort(PlatformFile file, int64 offset,
|
| char* data, int size) {
|
| base::ThreadRestrictions::AssertIOAllowed();
|
| @@ -204,6 +225,25 @@ int WritePlatformFile(PlatformFile file, int64 offset,
|
| return bytes_written ? bytes_written : rv;
|
| }
|
|
|
| +int WritePlatformFileFromCurrentPos(PlatformFile file,
|
| + const char* data, int size) {
|
| + base::ThreadRestrictions::AssertIOAllowed();
|
| + if (file < 0 || size < 0)
|
| + return -1;
|
| +
|
| + int bytes_written = 0;
|
| + int rv;
|
| + do {
|
| + rv = HANDLE_EINTR(write(file, data, size));
|
| + if (rv <= 0)
|
| + break;
|
| +
|
| + bytes_written += rv;
|
| + } while (bytes_written < size);
|
| +
|
| + return bytes_written ? bytes_written : rv;
|
| +}
|
| +
|
| bool TruncatePlatformFile(PlatformFile file, int64 length) {
|
| base::ThreadRestrictions::AssertIOAllowed();
|
| return ((file >= 0) && !HANDLE_EINTR(ftruncate(file, length)));
|
|
|