summaryrefslogtreecommitdiffstats
path: root/base/file_util_posix.cc
diff options
context:
space:
mode:
Diffstat (limited to 'base/file_util_posix.cc')
-rw-r--r--base/file_util_posix.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc
index 6a36c62..f571c5e 100644
--- a/base/file_util_posix.cc
+++ b/base/file_util_posix.cc
@@ -316,6 +316,18 @@ bool GetFileCreationLocalTime(const std::string& filename,
}
#endif
+bool ReadFromFD(int fd, char* buffer, size_t bytes) {
+ size_t total_read = 0;
+ while (total_read < bytes) {
+ ssize_t bytes_read = read(fd, buffer + total_read, bytes - total_read);
+ if (bytes_read > 0)
+ total_read += bytes_read;
+ else if (errno != EINTR || bytes_read == 0)
+ break;
+ }
+ return total_read == bytes;
+}
+
// Creates and opens a temporary file in |directory|, returning the
// file descriptor. |path| is set to the temporary file path.
// Note TODO(erikkay) comment in header for BlahFileName() calls; the