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

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

Issue 1419673007: Remove usage of compat from client (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 5 years, 1 month 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 | « client/client_test.gyp ('k') | util/file/file_io_posix.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 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 //! \brief Platform-specific alias for a position in an open file. 61 //! \brief Platform-specific alias for a position in an open file.
62 using FileOffset = off_t; 62 using FileOffset = off_t;
63 63
64 //! \brief Scoped wrapper of a FileHandle. 64 //! \brief Scoped wrapper of a FileHandle.
65 using ScopedFileHandle = base::ScopedFD; 65 using ScopedFileHandle = base::ScopedFD;
66 66
67 //! \brief A value that can never be a valid FileHandle. 67 //! \brief A value that can never be a valid FileHandle.
68 const FileHandle kInvalidFileHandle = -1; 68 const FileHandle kInvalidFileHandle = -1;
69 69
70 using FileOperationResult = ssize_t;
71
70 #elif defined(OS_WIN) 72 #elif defined(OS_WIN)
71 73
72 using FileHandle = HANDLE; 74 using FileHandle = HANDLE;
73 using FileOffset = LONGLONG; 75 using FileOffset = LONGLONG;
74 using ScopedFileHandle = ScopedFileHANDLE; 76 using ScopedFileHandle = ScopedFileHANDLE;
77 using FileOperationResult = LONG_PTR;
75 78
76 const FileHandle kInvalidFileHandle = INVALID_HANDLE_VALUE; 79 const FileHandle kInvalidFileHandle = INVALID_HANDLE_VALUE;
77 80
78 #endif 81 #endif
79 82
80 //! \brief Determines the mode that LoggingOpenFileForWrite() uses. 83 //! \brief Determines the mode that LoggingOpenFileForWrite() uses.
81 enum class FileWriteMode { 84 enum class FileWriteMode {
82 //! \brief Opens the file if it exists, or fails if it does not. 85 //! \brief Opens the file if it exists, or fails if it does not.
83 kReuseOrFail, 86 kReuseOrFail,
84 87
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 //! sockets is not currently supported. 122 //! sockets is not currently supported.
120 //! 123 //!
121 //! \return The number of bytes read and placed into \a buffer, or `-1` on 124 //! \return The number of bytes read and placed into \a buffer, or `-1` on
122 //! error, with `errno` or `GetLastError()` set appropriately. On error, a 125 //! error, with `errno` or `GetLastError()` set appropriately. On error, a
123 //! portion of \a file may have been read into \a buffer. 126 //! portion of \a file may have been read into \a buffer.
124 //! 127 //!
125 //! \sa WriteFile 128 //! \sa WriteFile
126 //! \sa LoggingReadFile 129 //! \sa LoggingReadFile
127 //! \sa CheckedReadFile 130 //! \sa CheckedReadFile
128 //! \sa CheckedReadFileAtEOF 131 //! \sa CheckedReadFileAtEOF
129 ssize_t ReadFile(FileHandle file, void* buffer, size_t size); 132 FileOperationResult ReadFile(FileHandle file, void* buffer, size_t size);
130 133
131 //! \brief Writes to a file, retrying when interrupted or following a short 134 //! \brief Writes to a file, retrying when interrupted or following a short
132 //! write on POSIX. 135 //! write on POSIX.
133 //! 136 //!
134 //! This function writes to \a file, stopping only when \a size bytes have been 137 //! This function writes to \a file, stopping only when \a size bytes have been
135 //! written. 138 //! written.
136 //! 139 //!
137 //! \return The number of bytes written from \a buffer, or `-1` on error, with 140 //! \return The number of bytes written from \a buffer, or `-1` on error, with
138 //! `errno` or `GetLastError()` set appropriately. On error, a portion of 141 //! `errno` or `GetLastError()` set appropriately. On error, a portion of
139 //! \a buffer may have been written to \a file. 142 //! \a buffer may have been written to \a file.
140 //! 143 //!
141 //! \sa ReadFile 144 //! \sa ReadFile
142 //! \sa LoggingWriteFile 145 //! \sa LoggingWriteFile
143 //! \sa CheckedWriteFile 146 //! \sa CheckedWriteFile
144 ssize_t WriteFile(FileHandle file, const void* buffer, size_t size); 147 FileOperationResult WriteFile(FileHandle file, const void* buffer, size_t size);
145 148
146 //! \brief Wraps ReadFile(), ensuring that exactly \a size bytes are read. 149 //! \brief Wraps ReadFile(), ensuring that exactly \a size bytes are read.
147 //! 150 //!
148 //! \return `true` on success. If \a size is out of the range of possible 151 //! \return `true` on success. If \a size is out of the range of possible
149 //! ReadFile() return values, if the underlying ReadFile() fails, or if 152 //! ReadFile() return values, if the underlying ReadFile() fails, or if
150 //! other than \a size bytes were read, this function logs a message and 153 //! other than \a size bytes were read, this function logs a message and
151 //! returns `false`. 154 //! returns `false`.
152 //! 155 //!
153 //! \sa LoggingWriteFile 156 //! \sa LoggingWriteFile
154 //! \sa ReadFile 157 //! \sa ReadFile
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 338
336 //! \brief Wraps `close()` or `CloseHandle()`, ensuring that it succeeds. 339 //! \brief Wraps `close()` or `CloseHandle()`, ensuring that it succeeds.
337 //! 340 //!
338 //! If the underlying function fails, this function causes execution to 341 //! If the underlying function fails, this function causes execution to
339 //! terminate without returning. 342 //! terminate without returning.
340 void CheckedCloseFile(FileHandle file); 343 void CheckedCloseFile(FileHandle file);
341 344
342 } // namespace crashpad 345 } // namespace crashpad
343 346
344 #endif // CRASHPAD_UTIL_FILE_FILE_IO_H_ 347 #endif // CRASHPAD_UTIL_FILE_FILE_IO_H_
OLDNEW
« no previous file with comments | « client/client_test.gyp ('k') | util/file/file_io_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698