Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(526)

Unified Diff: util/file/file_reader.cc

Issue 913223008: Add FileReaderInterface::ReadExactly() and FileSeekerInterface::SeekSet() (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « util/file/file_reader.h ('k') | util/file/file_seeker.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
}
« no previous file with comments | « util/file/file_reader.h ('k') | util/file/file_seeker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698