OLD | NEW |
1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 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 12 matching lines...) Expand all Loading... |
23 //! | 23 //! |
24 //! This function reads into \a buffer, stopping only when \a size bytes have | 24 //! This function reads into \a buffer, stopping only when \a size bytes have |
25 //! been read or when `read()` returns 0, indicating that end-of-file has been | 25 //! been read or when `read()` returns 0, indicating that end-of-file has been |
26 //! reached. | 26 //! reached. |
27 //! | 27 //! |
28 //! \return The number of bytes read and placed into \a buffer, or `-1` on | 28 //! \return The number of bytes read and placed into \a buffer, or `-1` on |
29 //! error, with `errno` set appropriately. On error, a portion of \a fd may | 29 //! error, with `errno` set appropriately. On error, a portion of \a fd may |
30 //! have been read into \a buffer. | 30 //! have been read into \a buffer. |
31 //! | 31 //! |
32 //! \sa WriteFD | 32 //! \sa WriteFD |
| 33 //! \sa CheckedReadFD |
| 34 //! \sa CheckedReadFDAtEOF |
33 ssize_t ReadFD(int fd, void* buffer, size_t size); | 35 ssize_t ReadFD(int fd, void* buffer, size_t size); |
34 | 36 |
35 //! \brief Wraps `write()`, retrying when interrupted or following a short | 37 //! \brief Wraps `write()`, retrying when interrupted or following a short |
36 //! write. | 38 //! write. |
37 //! | 39 //! |
38 //! This function writes to \a fd, stopping only when \a size bytes have been | 40 //! This function writes to \a fd, stopping only when \a size bytes have been |
39 //! written. | 41 //! written. |
40 //! | 42 //! |
41 //! \return The number of bytes written from \a buffer, or `-1` on error, with | 43 //! \return The number of bytes written from \a buffer, or `-1` on error, with |
42 //! `errno` set appropriately. On error, a portion of \a buffer may have | 44 //! `errno` set appropriately. On error, a portion of \a buffer may have |
43 //! been written to \a fd. | 45 //! been written to \a fd. |
44 //! | 46 //! |
45 //! \sa ReadFD | 47 //! \sa ReadFD |
| 48 //! \sa CheckedWriteFD |
46 ssize_t WriteFD(int fd, const void* buffer, size_t size); | 49 ssize_t WriteFD(int fd, const void* buffer, size_t size); |
47 | 50 |
| 51 //! \brief Wraps ReadFD(), ensuring that exactly \a size bytes are read. |
| 52 //! |
| 53 //! If \a size is out of the range of possible `read()` return values, if the |
| 54 //! underlying ReadFD() fails, or if other than \a size bytes were read, this |
| 55 //! function causes execution to terminate without returning. |
| 56 //! |
| 57 //! \sa CheckedWriteFD |
| 58 //! \sa ReadFD |
| 59 //! \sa CheckedReadFDAtEOF |
| 60 void CheckedReadFD(int fd, void* buffer, size_t size); |
| 61 |
| 62 //! \brief Wraps WriteFD(), ensuring that exactly \a size bytes are written. |
| 63 //! |
| 64 //! If \a size is out of the range of possible `write()` return values, if the |
| 65 //! underlying WriteFD() fails, or if other than \a size bytes were written, |
| 66 //! this function causes execution to terminate without returning. |
| 67 //! |
| 68 //! \sa CheckedReadFD |
| 69 //! \sa WriteFD |
| 70 void CheckedWriteFD(int fd, const void* buffer, size_t size); |
| 71 |
| 72 //! \brief Wraps ReadFD(), ensuring that it indicates end-of-file. |
| 73 //! |
| 74 //! Attempts to read a single byte from \a fd, expecting no data to be read. If |
| 75 //! the underlying ReadFD() fails, or if a byte actually is read, this function |
| 76 //! causes execution to terminate without returning. |
| 77 //! |
| 78 //! \sa CheckedReadFD |
| 79 //! \sa ReadFD |
| 80 void CheckedReadFDAtEOF(int fd); |
| 81 |
48 } // namespace crashpad | 82 } // namespace crashpad |
49 | 83 |
50 #endif // CRASHPAD_UTIL_FILE_FD_IO_H_ | 84 #endif // CRASHPAD_UTIL_FILE_FD_IO_H_ |
OLD | NEW |