Index: util/file/file_io.h |
diff --git a/util/file/file_io.h b/util/file/file_io.h |
index 927bc3cb13319ff5843a613cff77bbfd20588648..05fe7fe3c88f1be652d9284a175432795cab6cec 100644 |
--- a/util/file/file_io.h |
+++ b/util/file/file_io.h |
@@ -23,14 +23,32 @@ |
#include <windows.h> |
#endif |
+namespace base { |
+class FilePath; |
+} // namespace base |
+ |
namespace crashpad { |
-#if defined(OS_POSIX) |
+#if defined(OS_POSIX) || DOXYGEN |
+//! \brief Platform-specific alias for a low level file handle. |
Mark Mentovai
2014/12/18 22:20:59
nit: low-level
scottmg
2014/12/18 22:47:15
Done.
|
using FileHandle = int; |
#elif defined(OS_WIN) |
using FileHandle = HANDLE; |
#endif |
+//! \brief Determines the mode that LoggingOpenFileForWrite() uses. |
+enum class FileWriteMode { |
+ //! \brief Opens the file if it exists, or creates a new file. |
+ kReuseOrCreate, |
Mark Mentovai
2014/12/18 22:20:58
I agree about “reuse” but I couldn’t come up with
|
+ |
+ //! \brief Creates a new file. If the file already exists, it will be |
+ //! overwritten. |
Mark Mentovai
2014/12/18 22:20:58
Hanging indents are 4 spaces. Same on the function
scottmg
2014/12/18 22:47:15
Done.
|
+ kTruncateOrCreate, |
+ |
+ //! \brief Creates a new file. If the file already exists, the open will fail. |
+ kCreateOrFail, |
+}; |
+ |
//! \brief Reads from a file, retrying when interrupted on POSIX or following a |
//! short read. |
//! |
@@ -121,6 +139,33 @@ void CheckedWriteFile(FileHandle file, const void* buffer, size_t size); |
//! \sa ReadFile |
void CheckedReadFileAtEOF(FileHandle file); |
+//! \brief Wraps `open()` or `CreateFile()`, creating a file for output. Logs |
+//! an error if the operation fails. |
+//! |
+//! \a write_mode determines the style (truncate, reuse, etc.) that is used to |
+//! open the file. On POSIX, if \a world_readable, `0644` will be used as |
+//! `mode` permissions bits for `open()`, otherwise `0600` will be used. On |
+//! Windows, the file is always opened in binary mode (that is, no CRLF |
+//! translation). |
+//! |
+//! \return The newly opened FileHandle, or an invalid FileHandle on failure. |
+//! |
+//! \sa FileWriteMode |
+//! \sa ScopedFD |
+//! \sa ScopedFileHANDLE |
+FileHandle LoggingOpenFileForWrite(const base::FilePath& path, |
+ FileWriteMode write_mode, |
+ bool world_readable); |
+ |
+//! \brief Wraps `open()` or `CreateFile()`, opening an existing file for |
Mark Mentovai
2014/12/18 22:20:59
Nit: this file puts read ops before write ops, so
scottmg
2014/12/18 22:47:15
Done.
|
+//! reading. Logs an error if the operation fails. |
+//! |
+//! \return The newly opened FileHandle, or an invalid FileHandle on failure. |
+//! |
+//! \sa ScopedFD |
+//! \sa ScopedFileHANDLE |
+FileHandle LoggingOpenFileForRead(const base::FilePath& path); |
+ |
//! \brief Wraps `close()` or `CloseHandle()`, logging an error if the operation |
//! fails. |
//! |