| OLD | NEW |
| 1 // Copyright 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright 2006-2008 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/file_util.h" | 5 #include "base/file_util.h" |
| 6 | 6 |
| 7 #include <unistd.h> | 7 #include <unistd.h> |
| 8 | 8 |
| 9 #include "base/posix/eintr_wrapper.h" | 9 #include "base/posix/eintr_wrapper.h" |
| 10 | 10 |
| 11 namespace base { | 11 namespace base { |
| 12 | 12 |
| 13 bool ReadFromFD(int fd, char* buffer, size_t bytes) { | 13 bool ReadFromFD(int fd, char* buffer, size_t bytes) { |
| 14 size_t total_read = 0; | 14 size_t total_read = 0; |
| 15 while (total_read < bytes) { | 15 while (total_read < bytes) { |
| 16 ssize_t bytes_read = | 16 ssize_t bytes_read = |
| 17 HANDLE_EINTR(read(fd, buffer + total_read, bytes - total_read)); | 17 HANDLE_EINTR(read(fd, buffer + total_read, bytes - total_read)); |
| 18 if (bytes_read <= 0) { | 18 if (bytes_read <= 0) { |
| 19 break; | 19 break; |
| 20 } | 20 } |
| 21 total_read += bytes_read; | 21 total_read += bytes_read; |
| 22 } | 22 } |
| 23 return total_read == bytes; | 23 return total_read == bytes; |
| 24 } | 24 } |
| 25 | 25 |
| 26 } // namespace base | 26 } // namespace base |
| OLD | NEW |