Crashpad

Namespaces | Macros | Typedefs | Enumerations | Functions | Variables
file_io.h File Reference
`#include <sys/types.h>`
`#include "build/build_config.h"`

## Namespaces
| crashpad
| The main namespace.

## Macros
#define | STDIO_PLOG(x) PLOG(x)
| A `PLOG()` macro usable for standard input/output error conditions. More...

## Typedefs
using | crashpad::FileHandle = int
| Platform-specific alias for a low-level file handle.
using | crashpad::FileOffset = off_t
| Platform-specific alias for a position in an open file.
using | crashpad::ScopedFileHandle = base::ScopedFD
| Scoped wrapper of a FileHandle.
using | crashpad::FileOperationResult = ssize_t

## Enumerations
enum | crashpad::FileWriteMode
| Determines the mode that LoggingOpenFileForWrite() uses. More...
enum | crashpad::FilePermissions : bool
| Determines the permissions bits for files created on POSIX systems. More...
enum | crashpad::FileLocking : bool
| Determines the locking mode that LoggingLockFile() uses. More...

## Functions
FileOperationResult | crashpad::ReadFile (FileHandle file, void *buffer, size_t size)
| Reads from a file, retrying when interrupted on POSIX or following a short read. More...
FileOperationResult | crashpad::WriteFile (FileHandle file, const void *buffer, size_t size)
| Writes to a file, retrying when interrupted or following a short write on POSIX. More...
bool | crashpad::LoggingReadFile (FileHandle file, void *buffer, size_t size)
| Wraps ReadFile(), ensuring that exactly size bytes are read. More...
bool | crashpad::LoggingWriteFile (FileHandle file, const void *buffer, size_t size)
| Wraps WriteFile(), ensuring that exactly size bytes are written. More...
void | crashpad::CheckedReadFile (FileHandle file, void *buffer, size_t size)
| Wraps ReadFile(), ensuring that exactly size bytes are read. More...
void | crashpad::CheckedWriteFile (FileHandle file, const void *buffer, size_t size)
| Wraps WriteFile(), ensuring that exactly size bytes are written. More...
void | crashpad::CheckedReadFileAtEOF (FileHandle file)
| Wraps ReadFile(), ensuring that it indicates end-of-file. More...
FileHandle | crashpad::OpenFileForRead (const base::FilePath &path)
| Wraps `open()` or `CreateFile()`, opening an existing file for reading. More...
FileHandle | crashpad::OpenFileForWrite (const base::FilePath &path, FileWriteMode mode, FilePermissions permissions)
| Wraps `open()` or `CreateFile()`, creating a file for output. More...
FileHandle | crashpad::OpenFileForReadAndWrite (const base::FilePath &path, FileWriteMode mode, FilePermissions permissions)
| Wraps `open()` or `CreateFile()`, creating a file for both input and output. More...
FileHandle | crashpad::LoggingOpenFileForRead (const base::FilePath &path)
| Wraps OpenFileForRead(), logging an error if the operation fails. More...
FileHandle | crashpad::LoggingOpenFileForWrite (const base::FilePath &path, FileWriteMode mode, FilePermissions permissions)
| Wraps OpenFileForWrite(), logging an error if the operation fails. More...
FileHandle | crashpad::LoggingOpenFileForReadAndWrite (const base::FilePath &path, FileWriteMode mode, FilePermissions permissions)
| Wraps OpenFileForReadAndWrite(), logging an error if the operation fails. More...
bool | crashpad::LoggingLockFile (FileHandle file, FileLocking locking)
| Locks the given file using `flock()` on POSIX or `LockFileEx()` on Windows. More...
bool | crashpad::LoggingUnlockFile (FileHandle file)
| Unlocks a file previously locked with LoggingLockFile(). More...
FileOffset | crashpad::LoggingSeekFile (FileHandle file, FileOffset offset, int whence)
| Wraps `lseek()` or `SetFilePointerEx()`. Logs an error if the operation fails. More...
bool | crashpad::LoggingTruncateFile (FileHandle file)
| Truncates the given file to zero bytes in length. More...
bool | crashpad::LoggingCloseFile (FileHandle file)
| Wraps `close()` or `CloseHandle()`, logging an error if the operation fails. More...
void | crashpad::CheckedCloseFile (FileHandle file)
| Wraps `close()` or `CloseHandle()`, ensuring that it succeeds. More...
FileOffset | crashpad::LoggingFileSizeByHandle (FileHandle file)
| Determines the size of a file. More...

## Variables
const FileHandle | crashpad::kInvalidFileHandle = -1
| A value that can never be a valid FileHandle.

## Macro Definition Documentation

## ◆ STDIO_PLOG

#define STDIO_PLOG | ( |  | x | ) | PLOG(x)

A `PLOG()` macro usable for standard input/output error conditions.

The `PLOG()` macro uses `errno` on POSIX and is appropriate to report errors from standard input/output functions. On Windows, `PLOG()` uses `GetLastError()`, and cannot be used to report errors from standard input/output functions. This macro uses `PLOG()` when appropriate for standard I/O functions, and `LOG()` otherwise.