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

Side by Side Diff: util/file/file_reader.h

Issue 1416493006: Change file op |ssize_t|s to FileOperationResult (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: fixes Created 5 years, 2 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 unified diff | Download patch
« no previous file with comments | « util/file/file_io.cc ('k') | util/file/file_reader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Crashpad Authors. All rights reserved. 1 // Copyright 2015 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 19 matching lines...) Expand all
30 class FileReaderInterface : public virtual FileSeekerInterface { 30 class FileReaderInterface : public virtual FileSeekerInterface {
31 public: 31 public:
32 virtual ~FileReaderInterface() {} 32 virtual ~FileReaderInterface() {}
33 33
34 //! \brief Wraps ReadFile(), or provides an implementation with identical 34 //! \brief Wraps ReadFile(), or provides an implementation with identical
35 //! semantics. 35 //! semantics.
36 //! 36 //!
37 //! \return The number of bytes actually read if the operation succeeded, 37 //! \return The number of bytes actually read if the operation succeeded,
38 //! which may be `0` or any positive value less than or equal to \a size. 38 //! which may be `0` or any positive value less than or equal to \a size.
39 //! `-1` if the operation failed, with an error message logged. 39 //! `-1` if the operation failed, with an error message logged.
40 virtual ssize_t Read(void* data, size_t size) = 0; 40 virtual FileOperationResult Read(void* data, size_t size) = 0;
41 41
42 //! \brief Wraps Read(), ensuring that the read succeeded and exactly \a size 42 //! \brief Wraps Read(), ensuring that the read succeeded and exactly \a size
43 //! bytes were read. 43 //! bytes were read.
44 //! 44 //!
45 //! Semantically, this behaves as LoggingReadFile(). 45 //! Semantically, this behaves as LoggingReadFile().
46 //! 46 //!
47 //! \return `true` if the operation succeeded, `false` if it failed, with an 47 //! \return `true` if the operation succeeded, `false` if it failed, with an
48 //! error message logged. Short reads are treated as failures. 48 //! error message logged. Short reads are treated as failures.
49 bool ReadExactly(void* data, size_t size); 49 bool ReadExactly(void* data, size_t size);
50 }; 50 };
(...skipping 11 matching lines...) Expand all
62 //! disk-based files. 62 //! disk-based files.
63 //! 63 //!
64 //! This class is expected to be used when other code is responsible for 64 //! This class is expected to be used when other code is responsible for
65 //! opening files and already provides file handles. 65 //! opening files and already provides file handles.
66 class WeakFileHandleFileReader : public FileReaderInterface { 66 class WeakFileHandleFileReader : public FileReaderInterface {
67 public: 67 public:
68 explicit WeakFileHandleFileReader(FileHandle file_handle); 68 explicit WeakFileHandleFileReader(FileHandle file_handle);
69 ~WeakFileHandleFileReader() override; 69 ~WeakFileHandleFileReader() override;
70 70
71 // FileReaderInterface: 71 // FileReaderInterface:
72 ssize_t Read(void* data, size_t size) override; 72 FileOperationResult Read(void* data, size_t size) override;
73 73
74 // FileSeekerInterface: 74 // FileSeekerInterface:
75 75
76 //! \copydoc FileReaderInterface::Seek() 76 //! \copydoc FileReaderInterface::Seek()
77 //! 77 //!
78 //! \note This method is only guaranteed to function on file handles referring 78 //! \note This method is only guaranteed to function on file handles referring
79 //! to disk-based files. 79 //! to disk-based files.
80 FileOffset Seek(FileOffset offset, int whence) override; 80 FileOffset Seek(FileOffset offset, int whence) override;
81 81
82 private: 82 private:
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 //! successful Open() that has not yet been matched by a subsequent call 118 //! successful Open() that has not yet been matched by a subsequent call
119 //! to this method. 119 //! to this method.
120 void Close(); 120 void Close();
121 121
122 // FileReaderInterface: 122 // FileReaderInterface:
123 123
124 //! \copydoc FileReaderInterface::Read() 124 //! \copydoc FileReaderInterface::Read()
125 //! 125 //!
126 //! \note It is only valid to call this method between a successful Open() and 126 //! \note It is only valid to call this method between a successful Open() and
127 //! a Close(). 127 //! a Close().
128 ssize_t Read(void* data, size_t size) override; 128 FileOperationResult Read(void* data, size_t size) override;
129 129
130 // FileSeekerInterface: 130 // FileSeekerInterface:
131 131
132 //! \copydoc FileReaderInterface::Seek() 132 //! \copydoc FileReaderInterface::Seek()
133 //! 133 //!
134 //! \note It is only valid to call this method between a successful Open() and 134 //! \note It is only valid to call this method between a successful Open() and
135 //! a Close(). 135 //! a Close().
136 FileOffset Seek(FileOffset offset, int whence) override; 136 FileOffset Seek(FileOffset offset, int whence) override;
137 137
138 private: 138 private:
(...skipping 14 matching lines...) Expand all
153 //! 153 //!
154 //! This class is expected to be used when other code is responsible for 154 //! This class is expected to be used when other code is responsible for
155 //! opening `FILE*` objects and already provides `FILE*` objects. A good use 155 //! opening `FILE*` objects and already provides `FILE*` objects. A good use
156 //! would be a WeakStdioFileReader for `stdin`. 156 //! would be a WeakStdioFileReader for `stdin`.
157 class WeakStdioFileReader : public FileReaderInterface { 157 class WeakStdioFileReader : public FileReaderInterface {
158 public: 158 public:
159 explicit WeakStdioFileReader(FILE* file); 159 explicit WeakStdioFileReader(FILE* file);
160 ~WeakStdioFileReader() override; 160 ~WeakStdioFileReader() override;
161 161
162 // FileReaderInterface: 162 // FileReaderInterface:
163 ssize_t Read(void* data, size_t size) override; 163 FileOperationResult Read(void* data, size_t size) override;
164 164
165 // FileSeekerInterface: 165 // FileSeekerInterface:
166 166
167 //! \copydoc FileReaderInterface::Seek() 167 //! \copydoc FileReaderInterface::Seek()
168 //! 168 //!
169 //! \note This method is only guaranteed to function on `FILE*` objects 169 //! \note This method is only guaranteed to function on `FILE*` objects
170 //! referring to disk-based files. 170 //! referring to disk-based files.
171 FileOffset Seek(FileOffset offset, int whence) override; 171 FileOffset Seek(FileOffset offset, int whence) override;
172 172
173 private: 173 private:
174 FILE* file_; // weak 174 FILE* file_; // weak
175 175
176 DISALLOW_COPY_AND_ASSIGN(WeakStdioFileReader); 176 DISALLOW_COPY_AND_ASSIGN(WeakStdioFileReader);
177 }; 177 };
178 178
179 } // namespace crashpad 179 } // namespace crashpad
180 180
181 #endif // CRASHPAD_UTIL_FILE_FILE_READER_H_ 181 #endif // CRASHPAD_UTIL_FILE_FILE_READER_H_
OLDNEW
« no previous file with comments | « util/file/file_io.cc ('k') | util/file/file_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698