Chromium Code Reviews| 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, |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
| 13 // limitations under the License. | 13 // limitations under the License. |
| 14 | 14 |
| 15 #ifndef CRASHPAD_UTIL_FILE_FILE_IO_H_ | 15 #ifndef CRASHPAD_UTIL_FILE_FILE_IO_H_ |
| 16 #define CRASHPAD_UTIL_FILE_FILE_IO_H_ | 16 #define CRASHPAD_UTIL_FILE_FILE_IO_H_ |
| 17 | 17 |
| 18 #include <inttypes.h> | |
|
Mark Mentovai
2014/12/18 19:04:27
We use <stdint.h> to get intxx_t in Crashpad.
But
scottmg
2014/12/18 19:59:20
Done. (removed)
| |
| 18 #include <sys/types.h> | 19 #include <sys/types.h> |
| 19 | 20 |
| 20 #include "build/build_config.h" | 21 #include "build/build_config.h" |
| 21 | 22 |
| 22 #if defined(OS_WIN) | 23 #if defined(OS_WIN) |
| 23 #include <windows.h> | 24 #include <windows.h> |
| 24 #endif | 25 #endif |
| 25 | 26 |
| 27 namespace base { | |
| 28 class FilePath; | |
| 29 } | |
|
Mark Mentovai
2014/12/18 19:04:27
// namespace base
scottmg
2014/12/18 19:59:20
Done.
| |
| 30 | |
| 26 namespace crashpad { | 31 namespace crashpad { |
| 27 | 32 |
| 28 #if defined(OS_POSIX) | 33 #if defined(OS_POSIX) |
| 29 using FileHandle = int; | 34 using FileHandle = int; |
| 30 #elif defined(OS_WIN) | 35 #elif defined(OS_WIN) |
| 31 using FileHandle = HANDLE; | 36 using FileHandle = HANDLE; |
| 32 #endif | 37 #endif |
| 33 | 38 |
| 34 //! \brief Reads from a file, retrying when interrupted on POSIX or following a | 39 //! \brief Reads from a file, retrying when interrupted on POSIX or following a |
| 35 //! short read. | 40 //! short read. |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 114 //! \brief Wraps ReadFile(), ensuring that it indicates end-of-file. | 119 //! \brief Wraps ReadFile(), ensuring that it indicates end-of-file. |
| 115 //! | 120 //! |
| 116 //! Attempts to read a single byte from \a file, expecting no data to be read. | 121 //! Attempts to read a single byte from \a file, expecting no data to be read. |
| 117 //! If the underlying ReadFile() fails, or if a byte actually is read, this | 122 //! If the underlying ReadFile() fails, or if a byte actually is read, this |
| 118 //! function causes execution to terminate without returning. | 123 //! function causes execution to terminate without returning. |
| 119 //! | 124 //! |
| 120 //! \sa CheckedReadFile | 125 //! \sa CheckedReadFile |
| 121 //! \sa ReadFile | 126 //! \sa ReadFile |
| 122 void CheckedReadFileAtEOF(FileHandle file); | 127 void CheckedReadFileAtEOF(FileHandle file); |
| 123 | 128 |
| 129 //! \brief Wraps `open()` or `CreateFile()`, creating a file for output. Logs | |
| 130 //! an error if the operation fails. | |
| 131 //! | |
| 132 //! On a POSIX system, \a mode will be used as the permissions bits. | |
| 133 //! | |
| 134 //! \return The newly opened FileHandle, or an invalid FileHandle on failure. | |
|
Mark Mentovai
2014/12/18 19:04:27
Aha! We should have a \brief on FileHandle.
None
scottmg
2014/12/18 19:59:20
Done.
| |
| 135 //! | |
| 136 //! \sa ScopedFD | |
| 137 //! \sa ScopedFileHANDLE | |
| 138 FileHandle LoggingOpenFileForWrite(const base::FilePath& path, uint32_t mode); | |
|
Mark Mentovai
2014/12/18 19:04:26
I agree that we probably don’t need to worry about
scottmg
2014/12/18 19:59:20
I was thinking a separate LoggingOpenFileForAppend
| |
| 139 | |
| 140 //! \brief Wraps `open()` or `CreateFile()`, opening an existing file for | |
| 141 //! reading. Logs an error if the operation fails. | |
| 142 //! | |
| 143 //! \return The newly opened FileHandle, or an invalid FileHandle on failure. | |
| 144 //! | |
| 145 //! \sa ScopedFD | |
| 146 //! \sa ScopedFileHANDLE | |
| 147 FileHandle LoggingOpenFileForRead(const base::FilePath& path); | |
|
Mark Mentovai
2014/12/18 19:04:26
On the other hand, I see no problems with an inter
| |
| 148 | |
| 124 //! \brief Wraps `close()` or `CloseHandle()`, logging an error if the operation | 149 //! \brief Wraps `close()` or `CloseHandle()`, logging an error if the operation |
| 125 //! fails. | 150 //! fails. |
| 126 //! | 151 //! |
| 127 //! \return On success, `true` is returned. On failure, an error is logged and | 152 //! \return On success, `true` is returned. On failure, an error is logged and |
| 128 //! `false` is returned. | 153 //! `false` is returned. |
| 129 bool LoggingCloseFile(FileHandle file); | 154 bool LoggingCloseFile(FileHandle file); |
| 130 | 155 |
| 131 //! \brief Wraps `close()` or `CloseHandle()`, ensuring that it succeeds. | 156 //! \brief Wraps `close()` or `CloseHandle()`, ensuring that it succeeds. |
| 132 //! | 157 //! |
| 133 //! If the underlying function fails, this function causes execution to | 158 //! If the underlying function fails, this function causes execution to |
| 134 //! terminate without returning. | 159 //! terminate without returning. |
| 135 void CheckedCloseFile(FileHandle file); | 160 void CheckedCloseFile(FileHandle file); |
| 136 | 161 |
| 137 } // namespace crashpad | 162 } // namespace crashpad |
| 138 | 163 |
| 139 #endif // CRASHPAD_UTIL_FILE_FILE_IO_H_ | 164 #endif // CRASHPAD_UTIL_FILE_FILE_IO_H_ |
| OLD | NEW |