Crashpad
Public Member Functions | Friends | List of all members
crashpad::WeakFileHandleFileWriter Class Reference

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

#include "util/file/file_writer.h"

Inheritance diagram for crashpad::WeakFileHandleFileWriter:
crashpad::FileWriterInterface crashpad::FileSeekerInterface

Public Member Functions

 WeakFileHandleFileWriter (FileHandle file_handle)
 
bool Write (const void *data, size_t size) override
 Wraps LoggingWriteFile(), or provides an implementation with identical semantics. More...
 
bool WriteIoVec (std::vector< WritableIoVec > *iovecs) override
 Wraps writev() on POSIX or provides an alternate implementation with identical semantics. This method will write entire buffers, continuing after a short write or after being interrupted. On non-POSIX this is a simple wrapper around Write(). 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::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 FileWriter
 

Detailed Description

A file writer backed by a FileHandle.

FileWriter requires users to provide a FilePath to open, but this class accepts an already-open FileHandle instead. Like FileWriter, this class may write to a filesystem-based file, but unlike FileWriter, this class is not responsible for creating 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 write to 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 creating files and already provides file handles.

Member Function Documentation

◆ Seek()

FileOffset crashpad::WeakFileHandleFileWriter::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.

◆ Write()

bool crashpad::WeakFileHandleFileWriter::Write ( const void *  data,
size_t  size 
)
overridevirtual

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

Returns
true if the operation succeeded, false if it failed, with an error message logged.

Implements crashpad::FileWriterInterface.

◆ WriteIoVec()

bool crashpad::WeakFileHandleFileWriter::WriteIoVec ( std::vector< WritableIoVec > *  iovecs)
overridevirtual

Wraps writev() on POSIX or provides an alternate implementation with identical semantics. This method will write entire buffers, continuing after a short write or after being interrupted. On non-POSIX this is a simple wrapper around Write().

Returns
true if the operation succeeded, false if it failed, with an error message logged.
Note
The contents of iovecs are undefined when this method returns.

Implements crashpad::FileWriterInterface.


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