crashpad::WeakFileHandleFileReader Class Reference

A file reader backed by a FileHandle. More...

`#include "util/file/file_reader.h"`

Inheritance diagram for crashpad::WeakFileHandleFileReader:

## Public Member Functions

| WeakFileHandleFileReader (FileHandle file_handle)
FileOperationResult | Read (void *data, size_t size) override
| Wraps ReadFile(), or provides an implementation with identical semantics. More...
FileOffset | Seek (FileOffset offset, int whence) override
| Wraps LoggingSeekFile() or provides an alternate implementation with identical semantics. More...
Public Member Functions inherited from crashpad::FileReaderInterface
bool | ReadExactly (void *data, size_t size)
| Wraps Read(), ensuring that the read succeeded and exactly size bytes were read. More...
Public Member Functions inherited from crashpad::FileSeekerInterface
FileOffset | SeekGet ()
| Wraps Seek(), using `SEEK_CUR` to obtain the file’s current position. More...
bool | SeekSet (FileOffset offset)
| Wraps Seek(), using `SEEK_SET`, ensuring that the seek succeeded and the file is positioned as desired. More...

## Friends

class | FileReader

## Detailed Description

A file reader backed by a FileHandle.

FileReader requires users to provide a FilePath to open, but this class accepts an already-open FileHandle instead. Like FileReader, this class may read from a filesystem-based file, but unlike FileReader, this class is not responsible for opening or closing the file. Users of this class must ensure that the file handle is closed appropriately elsewhere. Objects of this class may be used to read from file handles not associated with filesystem-based files, although special attention should be paid to the Seek() method, which may not function on file handles that do not refer to disk-based files.

This class is expected to be used when other code is responsible for opening files and already provides file handles.

## Member Function Documentation

## Read()

FileOperationResult crashpad::WeakFileHandleFileReader::Read | ( | void * | data,
|  | size_t | size
| ) |  |

overridevirtual

Wraps ReadFile(), or provides an implementation with identical semantics.

Returns
  The number of bytes actually read if the operation succeeded, which may be `0` or any positive value less than or equal to size. `-1` if the operation failed, with an error message logged.

Implements crashpad::FileReaderInterface.

## Seek()

FileOffset crashpad::WeakFileHandleFileReader::Seek | ( | FileOffset | offset,
|  | int | whence
| ) |  |

overridevirtual

Wraps LoggingSeekFile() or provides an alternate implementation with identical semantics.

Returns
  The return value of LoggingSeekFile(). `-1` on failure, with an error message logged.

Note
  This method is only guaranteed to function on file handles referring to disk-based files.

Implements crashpad::FileSeekerInterface.

The documentation for this class was generated from the following files:

- util/file/file_reader.h
- util/file/file_reader.cc