| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/file_util.h" | |
| 6 | |
| 7 #include <unistd.h> | |
| 8 | |
| 9 #include "base/posix/eintr_wrapper.h" | |
| 10 | |
| 11 namespace base { | |
| 12 | |
| 13 bool ReadFromFD(int fd, char* buffer, size_t bytes) { | |
| 14 size_t total_read = 0; | |
| 15 while (total_read < bytes) { | |
| 16 ssize_t bytes_read = | |
| 17 HANDLE_EINTR(read(fd, buffer + total_read, bytes - total_read)); | |
| 18 if (bytes_read <= 0) { | |
| 19 break; | |
| 20 } | |
| 21 total_read += bytes_read; | |
| 22 } | |
| 23 return total_read == bytes; | |
| 24 } | |
| 25 | |
| 26 } // namespace base | |
| OLD | NEW |