1 // Copyright 2012 The Chromium Authors 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 "partition_alloc/partition_alloc_base/files/file_util.h" 6 7 #include "partition_alloc/partition_alloc_base/posix/eintr_wrapper.h" 8 9 namespace partition_alloc::internal::base { 10 ReadFromFD(int fd,char * buffer,size_t bytes)11bool ReadFromFD(int fd, char* buffer, size_t bytes) { 12 size_t total_read = 0; 13 while (total_read < bytes) { 14 ssize_t bytes_read = 15 WrapEINTR(read)(fd, buffer + total_read, bytes - total_read); 16 if (bytes_read <= 0) { 17 break; 18 } 19 total_read += bytes_read; 20 } 21 return total_read == bytes; 22 } 23 24 } // namespace partition_alloc::internal::base 25