Index: util/file/file_reader.cc |
diff --git a/util/file/file_reader.cc b/util/file/file_reader.cc |
index b6fd0173e262b294f4acb67f1cc85781bdbfe7b9..c983f4f6e9ba0b22940f125c7a74c1a898ad2d15 100644 |
--- a/util/file/file_reader.cc |
+++ b/util/file/file_reader.cc |
@@ -19,6 +19,20 @@ |
namespace crashpad { |
+bool FileReaderInterface::ReadExactly(void* data, size_t size) { |
+ ssize_t expect = base::checked_cast<ssize_t>(size); |
+ ssize_t rv = Read(data, size); |
+ if (rv < 0) { |
+ // Read() will have logged its own error. |
+ return false; |
+ } else if (rv != expect) { |
+ LOG(ERROR) << "ReadExactly(): expected " << expect << ", observed " << rv; |
+ return false; |
+ } |
+ |
+ return true; |
+} |
+ |
WeakFileHandleFileReader::WeakFileHandleFileReader(FileHandle file_handle) |
: file_handle_(file_handle) { |
} |