| 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 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 //! \brief Platform-specific alias for a low-level file handle. | 37 //! \brief Platform-specific alias for a low-level file handle. |
| 38 using FileHandle = int; | 38 using FileHandle = int; |
| 39 | 39 |
| 40 //! \brief Platform-specific alias for a position in an open file. | 40 //! \brief Platform-specific alias for a position in an open file. |
| 41 using FileOffset = off_t; | 41 using FileOffset = off_t; |
| 42 | 42 |
| 43 //! \brief Scoped wrapper of a FileHandle. | 43 //! \brief Scoped wrapper of a FileHandle. |
| 44 using ScopedFileHandle = base::ScopedFD; | 44 using ScopedFileHandle = base::ScopedFD; |
| 45 | 45 |
| 46 //! \brief A value that can never be a valid FileHandle. |
| 47 const FileHandle kInvalidFileHandle = -1; |
| 48 |
| 46 #elif defined(OS_WIN) | 49 #elif defined(OS_WIN) |
| 47 | 50 |
| 48 using FileHandle = HANDLE; | 51 using FileHandle = HANDLE; |
| 49 using FileOffset = LONGLONG; | 52 using FileOffset = LONGLONG; |
| 50 using ScopedFileHandle = ScopedFileHANDLE; | 53 using ScopedFileHandle = ScopedFileHANDLE; |
| 51 | 54 |
| 55 const FileHandle kInvalidFileHandle = INVALID_HANDLE_VALUE; |
| 56 |
| 52 #endif | 57 #endif |
| 53 | 58 |
| 54 //! \brief Determines the mode that LoggingOpenFileForWrite() uses. | 59 //! \brief Determines the mode that LoggingOpenFileForWrite() uses. |
| 55 enum class FileWriteMode { | 60 enum class FileWriteMode { |
| 56 //! \brief Opens the file if it exists, or creates a new file. | 61 //! \brief Opens the file if it exists, or creates a new file. |
| 57 kReuseOrCreate, | 62 kReuseOrCreate, |
| 58 | 63 |
| 59 //! \brief Creates a new file. If the file already exists, it will be | 64 //! \brief Creates a new file. If the file already exists, it will be |
| 60 //! overwritten. | 65 //! overwritten. |
| 61 kTruncateOrCreate, | 66 kTruncateOrCreate, |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 | 213 |
| 209 //! \brief Wraps `close()` or `CloseHandle()`, ensuring that it succeeds. | 214 //! \brief Wraps `close()` or `CloseHandle()`, ensuring that it succeeds. |
| 210 //! | 215 //! |
| 211 //! If the underlying function fails, this function causes execution to | 216 //! If the underlying function fails, this function causes execution to |
| 212 //! terminate without returning. | 217 //! terminate without returning. |
| 213 void CheckedCloseFile(FileHandle file); | 218 void CheckedCloseFile(FileHandle file); |
| 214 | 219 |
| 215 } // namespace crashpad | 220 } // namespace crashpad |
| 216 | 221 |
| 217 #endif // CRASHPAD_UTIL_FILE_FILE_IO_H_ | 222 #endif // CRASHPAD_UTIL_FILE_FILE_IO_H_ |
| OLD | NEW |