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

Unified Diff: util/file/file_reader.h

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 | « no previous file | util/file/file_reader.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: util/file/file_reader.h
diff --git a/util/file/file_reader.h b/util/file/file_reader.h
index 825a38e45e9ea82ec5d708252f28dbc9097e08af..2d699cb43215aaea1ce5ce4be8ac111e1a067529 100644
--- a/util/file/file_reader.h
+++ b/util/file/file_reader.h
@@ -26,7 +26,7 @@ namespace crashpad {
//! \brief An interface to read to files and other file-like objects with
//! semantics matching the underlying platform (POSIX or Windows).
-class FileReaderInterface : public FileSeekerInterface {
+class FileReaderInterface : public virtual FileSeekerInterface {
public:
//! \brief Wraps ReadFile(), or provides an implementation with identical
//! semantics.
@@ -36,6 +36,15 @@ class FileReaderInterface : public FileSeekerInterface {
//! `-1` if the operation failed, with an error message logged.
virtual ssize_t Read(void* data, size_t size) = 0;
+ //! \brief Wraps Read(), ensuring that the read succeeded and exactly \a size
+ //! bytes were read.
+ //!
+ //! Semantically, this behaves as LoggingReadFile().
+ //!
+ //! \return `true` if the operation succeeded, `false` if it failed, with an
+ //! error message logged. Short reads are treated as failures.
+ bool ReadExactly(void* data, size_t size);
+
protected:
~FileReaderInterface() {}
};
« no previous file with comments | « no previous file | util/file/file_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698