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

A file writer backed by a standard input/output FILE*. More...

#include "util/file/file_writer.h"

Inheritance diagram for crashpad::WeakStdioFileWriter:
crashpad::FileWriterInterface crashpad::FileSeekerInterface

Public Member Functions

 WeakStdioFileWriter (FILE *file)
 
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...
 

Detailed Description

A file writer backed by a standard input/output FILE*.

This class accepts an already-open FILE*. It is not responsible for opening or closing this FILE*. Users of this class must ensure that the FILE* is closed appropriately elsewhere. Objects of this class may be used to write to FILE* objects not associated with filesystem-based files, although special attention should be paid to the Seek() method, which may not function on FILE* objects that do not refer to disk-based files.

This class is expected to be used when other code is responsible for opening FILE* objects and already provides FILE* objects. A good use would be a WeakStdioFileWriter for stdout.

Member Function Documentation

◆ Seek()

FileOffset crashpad::WeakStdioFileWriter::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* objects referring to disk-based files.

Implements crashpad::FileSeekerInterface.

◆ Write()

bool crashpad::WeakStdioFileWriter::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::WeakStdioFileWriter::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: