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 // This file contains utility functions for dealing with the local 6 // filesystem. 7 8 #ifndef PARTITION_ALLOC_PARTITION_ALLOC_BASE_FILES_FILE_UTIL_H_ 9 #define PARTITION_ALLOC_PARTITION_ALLOC_BASE_FILES_FILE_UTIL_H_ 10 11 #include <cstddef> 12 #include <cstdint> 13 #include <cstdio> 14 15 #include "build/build_config.h" 16 #include "partition_alloc/partition_alloc_base/component_export.h" 17 18 #if BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) 19 #include <sys/stat.h> 20 #include <unistd.h> 21 #endif 22 23 namespace partition_alloc::internal::base { 24 25 #if BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) 26 27 // Read exactly |bytes| bytes from file descriptor |fd|, storing the result 28 // in |buffer|. This function is protected against EINTR and partial reads. 29 // Returns true iff |bytes| bytes have been successfully read from |fd|. 30 PA_COMPONENT_EXPORT(PARTITION_ALLOC_BASE) 31 bool ReadFromFD(int fd, char* buffer, size_t bytes); 32 33 #endif // BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) 34 35 } // namespace partition_alloc::internal::base 36 37 #endif // PARTITION_ALLOC_PARTITION_ALLOC_BASE_FILES_FILE_UTIL_H_ 38