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

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

Issue 821483002: Change 'bool world_readable' to an enum (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: fixes Created 6 years 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 | « tools/generate_dump.cc ('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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 kReuseOrCreate, 57 kReuseOrCreate,
58 58
59 //! \brief Creates a new file. If the file already exists, it will be 59 //! \brief Creates a new file. If the file already exists, it will be
60 //! overwritten. 60 //! overwritten.
61 kTruncateOrCreate, 61 kTruncateOrCreate,
62 62
63 //! \brief Creates a new file. If the file already exists, the open will fail. 63 //! \brief Creates a new file. If the file already exists, the open will fail.
64 kCreateOrFail, 64 kCreateOrFail,
65 }; 65 };
66 66
67 //! \brief Determines the permissions bits for files created on POSIX systems.
68 enum class FilePermissions : bool {
69 //! \brief Equivalent to `0600`.
70 kOwnerOnly,
71
72 //! \brief Equivalent to `0644`.
73 kWorldReadable,
74 };
75
67 //! \brief Reads from a file, retrying when interrupted on POSIX or following a 76 //! \brief Reads from a file, retrying when interrupted on POSIX or following a
68 //! short read. 77 //! short read.
69 //! 78 //!
70 //! This function reads into \a buffer, stopping only when \a size bytes have 79 //! This function reads into \a buffer, stopping only when \a size bytes have
71 //! been read or when end-of-file has been reached. On Windows, reading from 80 //! been read or when end-of-file has been reached. On Windows, reading from
72 //! sockets is not currently supported. 81 //! sockets is not currently supported.
73 //! 82 //!
74 //! \return The number of bytes read and placed into \a buffer, or `-1` on 83 //! \return The number of bytes read and placed into \a buffer, or `-1` on
75 //! error, with `errno` or `GetLastError()` set appropriately. On error, a 84 //! error, with `errno` or `GetLastError()` set appropriately. On error, a
76 //! portion of \a file may have been read into \a buffer. 85 //! portion of \a file may have been read into \a buffer.
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 //! 168 //!
160 //! \return The newly opened FileHandle, or an invalid FileHandle on failure. 169 //! \return The newly opened FileHandle, or an invalid FileHandle on failure.
161 //! 170 //!
162 //! \sa ScopedFileHandle 171 //! \sa ScopedFileHandle
163 FileHandle LoggingOpenFileForRead(const base::FilePath& path); 172 FileHandle LoggingOpenFileForRead(const base::FilePath& path);
164 173
165 //! \brief Wraps `open()` or `CreateFile()`, creating a file for output. Logs 174 //! \brief Wraps `open()` or `CreateFile()`, creating a file for output. Logs
166 //! an error if the operation fails. 175 //! an error if the operation fails.
167 //! 176 //!
168 //! \a write_mode determines the style (truncate, reuse, etc.) that is used to 177 //! \a write_mode determines the style (truncate, reuse, etc.) that is used to
169 //! open the file. On POSIX, if \a world_readable, `0644` will be used as 178 //! open the file. On POSIX, \a permissions determines the value that is passed
170 //! `mode` permissions bits for `open()`, otherwise `0600` will be used. On 179 //! as `mode` to `open()`. On Windows, the file is always opened in binary mode
171 //! Windows, the file is always opened in binary mode (that is, no CRLF 180 //! (that is, no CRLF translation).
172 //! translation).
173 //! 181 //!
174 //! \return The newly opened FileHandle, or an invalid FileHandle on failure. 182 //! \return The newly opened FileHandle, or an invalid FileHandle on failure.
175 //! 183 //!
176 //! \sa FileWriteMode 184 //! \sa FileWriteMode
185 //! \sa FilePermissions
177 //! \sa ScopedFileHandle 186 //! \sa ScopedFileHandle
178 FileHandle LoggingOpenFileForWrite(const base::FilePath& path, 187 FileHandle LoggingOpenFileForWrite(const base::FilePath& path,
179 FileWriteMode write_mode, 188 FileWriteMode write_mode,
180 bool world_readable); 189 FilePermissions permissions);
181 190
182 //! \brief Wraps `lseek()` or `SetFilePointerEx()`. Logs an error if the 191 //! \brief Wraps `lseek()` or `SetFilePointerEx()`. Logs an error if the
183 //! operation fails. 192 //! operation fails.
184 //! 193 //!
185 //! Repositions the offset of the open \a file to the specified \a offset, 194 //! Repositions the offset of the open \a file to the specified \a offset,
186 //! relative to \a whence. \a whence must be one of `SEEK_SET`, `SEEK_CUR`, or 195 //! relative to \a whence. \a whence must be one of `SEEK_SET`, `SEEK_CUR`, or
187 //! `SEEK_END`, and is interpreted in the usual way. 196 //! `SEEK_END`, and is interpreted in the usual way.
188 //! 197 //!
189 //! \return The resulting offset in bytes from the beginning of the file, or 198 //! \return The resulting offset in bytes from the beginning of the file, or
190 //! `-1` on failure. 199 //! `-1` on failure.
191 FileOffset LoggingSeekFile(FileHandle file, FileOffset offset, int whence); 200 FileOffset LoggingSeekFile(FileHandle file, FileOffset offset, int whence);
192 201
193 //! \brief Wraps `close()` or `CloseHandle()`, logging an error if the operation 202 //! \brief Wraps `close()` or `CloseHandle()`, logging an error if the operation
194 //! fails. 203 //! fails.
195 //! 204 //!
196 //! \return On success, `true` is returned. On failure, an error is logged and 205 //! \return On success, `true` is returned. On failure, an error is logged and
197 //! `false` is returned. 206 //! `false` is returned.
198 bool LoggingCloseFile(FileHandle file); 207 bool LoggingCloseFile(FileHandle file);
199 208
200 //! \brief Wraps `close()` or `CloseHandle()`, ensuring that it succeeds. 209 //! \brief Wraps `close()` or `CloseHandle()`, ensuring that it succeeds.
201 //! 210 //!
202 //! If the underlying function fails, this function causes execution to 211 //! If the underlying function fails, this function causes execution to
203 //! terminate without returning. 212 //! terminate without returning.
204 void CheckedCloseFile(FileHandle file); 213 void CheckedCloseFile(FileHandle file);
205 214
206 } // namespace crashpad 215 } // namespace crashpad
207 216
208 #endif // CRASHPAD_UTIL_FILE_FILE_IO_H_ 217 #endif // CRASHPAD_UTIL_FILE_FILE_IO_H_
OLDNEW
« no previous file with comments | « tools/generate_dump.cc ('k') | util/file/file_io_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698