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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 //! | 195 //! |
196 //! Attempts to read a single byte from \a file, expecting no data to be read. | 196 //! Attempts to read a single byte from \a file, expecting no data to be read. |
197 //! If the underlying ReadFile() fails, or if a byte actually is read, this | 197 //! If the underlying ReadFile() fails, or if a byte actually is read, this |
198 //! function causes execution to terminate without returning. | 198 //! function causes execution to terminate without returning. |
199 //! | 199 //! |
200 //! \sa CheckedReadFile | 200 //! \sa CheckedReadFile |
201 //! \sa ReadFile | 201 //! \sa ReadFile |
202 void CheckedReadFileAtEOF(FileHandle file); | 202 void CheckedReadFileAtEOF(FileHandle file); |
203 | 203 |
204 //! \brief Wraps `open()` or `CreateFile()`, opening an existing file for | 204 //! \brief Wraps `open()` or `CreateFile()`, opening an existing file for |
205 //! reading. Logs an error if the operation fails. | 205 //! reading. |
206 //! | 206 //! |
207 //! \return The newly opened FileHandle, or an invalid FileHandle on failure. | 207 //! \return The newly opened FileHandle, or an invalid FileHandle on failure. |
208 //! | 208 //! |
209 //! \sa ScopedFileHandle | 209 //! \sa ScopedFileHandle |
210 FileHandle LoggingOpenFileForRead(const base::FilePath& path); | 210 //! \sa OpenFileForWrite |
| 211 //! \sa OpenFileForReadAndWrite |
| 212 //! \sa LoggingOpenFileForRead |
| 213 FileHandle OpenFileForRead(const base::FilePath& path); |
211 | 214 |
212 //! \brief Wraps `open()` or `CreateFile()`, creating a file for output. Logs | 215 //! \brief Wraps `open()` or `CreateFile()`, creating a file for output. |
213 //! an error if the operation fails. | |
214 //! | 216 //! |
215 //! \a mode determines the style (truncate, reuse, etc.) that is used to open | 217 //! \a mode determines the style (truncate, reuse, etc.) that is used to open |
216 //! the file. On POSIX, \a permissions determines the value that is passed as | 218 //! the file. On POSIX, \a permissions determines the value that is passed as |
217 //! `mode` to `open()`. On Windows, the file is always opened in binary mode | 219 //! `mode` to `open()`. On Windows, the file is always opened in binary mode |
218 //! (that is, no CRLF translation). On Windows, the file is opened for sharing, | 220 //! (that is, no CRLF translation). On Windows, the file is opened for sharing, |
219 //! see LoggingLockFile() and LoggingUnlockFile() to control concurrent access. | 221 //! see LoggingLockFile() and LoggingUnlockFile() to control concurrent access. |
220 //! | 222 //! |
221 //! \return The newly opened FileHandle, or an invalid FileHandle on failure. | 223 //! \return The newly opened FileHandle, or an invalid FileHandle on failure. |
222 //! | 224 //! |
223 //! \sa FileWriteMode | |
224 //! \sa FilePermissions | |
225 //! \sa ScopedFileHandle | 225 //! \sa ScopedFileHandle |
226 FileHandle LoggingOpenFileForWrite(const base::FilePath& path, | 226 //! \sa OpenFileForRead |
227 FileWriteMode mode, | 227 //! \sa OpenFileForReadAndWrite |
228 FilePermissions permissions); | 228 //! \sa LoggingOpenFileForWrite |
| 229 FileHandle OpenFileForWrite(const base::FilePath& path, |
| 230 FileWriteMode mode, |
| 231 FilePermissions permissions); |
229 | 232 |
230 //! \brief Wraps `open()` or `CreateFile()`, creating a file for both input and | 233 //! \brief Wraps `open()` or `CreateFile()`, creating a file for both input and |
231 //! output. Logs an error if the operation fails. | 234 //! output. |
232 //! | 235 //! |
233 //! \a mode determines the style (truncate, reuse, etc.) that is used to open | 236 //! \a mode determines the style (truncate, reuse, etc.) that is used to open |
234 //! the file. On POSIX, \a permissions determines the value that is passed as | 237 //! the file. On POSIX, \a permissions determines the value that is passed as |
235 //! `mode` to `open()`. On Windows, the file is always opened in binary mode | 238 //! `mode` to `open()`. On Windows, the file is always opened in binary mode |
236 //! (that is, no CRLF translation). On Windows, the file is opened for sharing, | 239 //! (that is, no CRLF translation). On Windows, the file is opened for sharing, |
237 //! see LoggingLockFile() and LoggingUnlockFile() to control concurrent access. | 240 //! see LoggingLockFile() and LoggingUnlockFile() to control concurrent access. |
238 //! | 241 //! |
239 //! \return The newly opened FileHandle, or an invalid FileHandle on failure. | 242 //! \return The newly opened FileHandle, or an invalid FileHandle on failure. |
240 //! | 243 //! |
241 //! \sa FileWriteMode | |
242 //! \sa FilePermissions | |
243 //! \sa ScopedFileHandle | 244 //! \sa ScopedFileHandle |
| 245 //! \sa OpenFileForRead |
| 246 //! \sa OpenFileForWrite |
| 247 //! \sa LoggingOpenFileForReadAndWrite |
| 248 FileHandle OpenFileForReadAndWrite(const base::FilePath& path, |
| 249 FileWriteMode mode, |
| 250 FilePermissions permissions); |
| 251 |
| 252 //! \brief Wraps OpenFileForRead(), logging an error if the operation fails. |
| 253 //! |
| 254 //! \return The newly opened FileHandle, or an invalid FileHandle on failure. |
| 255 //! |
| 256 //! \sa ScopedFileHandle |
| 257 //! \sa LoggingOpenFileForWrite |
| 258 //! \sa LoggingOpenFileForReadAndWrite |
| 259 FileHandle LoggingOpenFileForRead(const base::FilePath& path); |
| 260 |
| 261 //! \brief Wraps OpenFileForWrite(), logging an error if the operation fails. |
| 262 //! |
| 263 //! \return The newly opened FileHandle, or an invalid FileHandle on failure. |
| 264 //! |
| 265 //! \sa ScopedFileHandle |
| 266 //! \sa LoggingOpenFileForRead |
| 267 //! \sa LoggingOpenFileForReadAndWrite |
| 268 FileHandle LoggingOpenFileForWrite(const base::FilePath& path, |
| 269 FileWriteMode mode, |
| 270 FilePermissions permissions); |
| 271 |
| 272 //! \brief Wraps OpenFileForReadAndWrite(), logging an error if the operation |
| 273 //! fails. |
| 274 //! |
| 275 //! \return The newly opened FileHandle, or an invalid FileHandle on failure. |
| 276 //! |
| 277 //! \sa ScopedFileHandle |
| 278 //! \sa LoggingOpenFileForRead |
| 279 //! \sa LoggingOpenFileForWrite |
244 FileHandle LoggingOpenFileForReadAndWrite(const base::FilePath& path, | 280 FileHandle LoggingOpenFileForReadAndWrite(const base::FilePath& path, |
245 FileWriteMode mode, | 281 FileWriteMode mode, |
246 FilePermissions permissions); | 282 FilePermissions permissions); |
247 | 283 |
248 //! \brief Locks the given \a file using `flock()` on POSIX or `LockFileEx()` on | 284 //! \brief Locks the given \a file using `flock()` on POSIX or `LockFileEx()` on |
249 //! Windows. | 285 //! Windows. |
250 //! | 286 //! |
251 //! It is an error to attempt to lock a file in a different mode when it is | 287 //! It is an error to attempt to lock a file in a different mode when it is |
252 //! already locked. This call will block until the lock is acquired. The | 288 //! already locked. This call will block until the lock is acquired. The |
253 //! entire file is locked. | 289 //! entire file is locked. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 | 335 |
300 //! \brief Wraps `close()` or `CloseHandle()`, ensuring that it succeeds. | 336 //! \brief Wraps `close()` or `CloseHandle()`, ensuring that it succeeds. |
301 //! | 337 //! |
302 //! If the underlying function fails, this function causes execution to | 338 //! If the underlying function fails, this function causes execution to |
303 //! terminate without returning. | 339 //! terminate without returning. |
304 void CheckedCloseFile(FileHandle file); | 340 void CheckedCloseFile(FileHandle file); |
305 | 341 |
306 } // namespace crashpad | 342 } // namespace crashpad |
307 | 343 |
308 #endif // CRASHPAD_UTIL_FILE_FILE_IO_H_ | 344 #endif // CRASHPAD_UTIL_FILE_FILE_IO_H_ |
OLD | NEW |