class raw_fd_ostream

Declaration

class raw_fd_ostream : public raw_pwrite_stream { /* full declaration omitted */ };

Description

A raw_ostream that writes to a file descriptor.

Declared at: llvm/include/llvm/Support/raw_ostream.h:444

Inherits from: raw_pwrite_stream

Member Variables

private int FD
private bool ShouldClose
private bool SupportsSeeking = false
private bool IsRegularFile = false
private Optional<bool> HasColors
private std::error_code EC
private uint64_t pos = 0

Inherited from raw_ostream:

public static BLACK = Colors::BLACK
public static RED = Colors::RED
public static GREEN = Colors::GREEN
public static YELLOW = Colors::YELLOW
public static BLUE = Colors::BLUE
public static MAGENTA = Colors::MAGENTA
public static CYAN = Colors::CYAN
public static WHITE = Colors::WHITE
public static SAVEDCOLOR = Colors::SAVEDCOLOR
public static RESET = Colors::RESET

Method Overview

  • private void anchor()
  • public void clear_error()
  • public void close()
  • private uint64_t current_pos() const
  • public std::error_code error() const
  • protected void error_detected(std::error_code EC)
  • protected int get_fd() const
  • public bool has_colors() const
  • public bool has_error() const
  • protected void inc_pos(uint64_t Delta)
  • public bool isRegularFile() const
  • public bool is_displayed() const
  • public Expected<sys::fs::FileLocker> lock()
  • private size_t preferred_buffer_size() const
  • private void pwrite_impl(const char * Ptr, size_t Size, uint64_t Offset)
  • public raw_fd_ostream(int fd, bool shouldClose, bool unbuffered = false, llvm::raw_ostream::OStreamKind K = OStreamKind::OK_OStream)
  • public raw_fd_ostream(llvm::StringRef Filename, std::error_code & EC, sys::fs::CreationDisposition Disp, sys::fs::FileAccess Access, sys::fs::OpenFlags Flags)
  • public raw_fd_ostream(llvm::StringRef Filename, std::error_code & EC, sys::fs::OpenFlags Flags)
  • public raw_fd_ostream(llvm::StringRef Filename, std::error_code & EC, sys::fs::FileAccess Access)
  • public raw_fd_ostream(llvm::StringRef Filename, std::error_code & EC, sys::fs::CreationDisposition Disp)
  • public raw_fd_ostream(llvm::StringRef Filename, std::error_code & EC)
  • public uint64_t seek(uint64_t off)
  • public bool supportsSeeking() const
  • public Expected<sys::fs::FileLocker> tryLockFor(const llvm::Duration & Timeout)
  • private void write_impl(const char * Ptr, size_t Size)
  • public ~raw_fd_ostream()

Inherited from raw_pwrite_stream:

Inherited from raw_ostream:

Methods

void anchor()

Declared at: llvm/include/llvm/Support/raw_ostream.h:473

void clear_error()

Description

Set the flag read by has_error() to false. If the error flag is set at the time when this raw_ostream's destructor is called, report_fatal_error is called to report the error. Use clear_error() after handling the error to avoid this behavior. "Errors should never pass silently. Unless explicitly silenced." - from The Zen of Python, by Tim Peters

Declared at: llvm/include/llvm/Support/raw_ostream.h:546

void close()

Description

Manually flush the stream and close the file. Note that this does not call fsync.

Declared at: llvm/include/llvm/Support/raw_ostream.h:515

uint64_t current_pos() const

Description

Return the current position within the stream, not counting the bytes currently in the buffer.

Declared at: llvm/include/llvm/Support/raw_ostream.h:468

std::error_code error() const

Declared at: llvm/include/llvm/Support/raw_ostream.h:529

void error_detected(std::error_code EC)

Description

Set the flag indicating that an output error has been encountered.

Declared at: llvm/include/llvm/Support/raw_ostream.h:477

Parameters

std::error_code EC

int get_fd() const

Description

Return the file descriptor.

Declared at: llvm/include/llvm/Support/raw_ostream.h:480

bool has_colors() const

Description

This function determines if this stream is displayed and supports colors. The result is unaffected by calls to enable_color().

Declared at: llvm/include/llvm/Support/raw_ostream.h:527

bool has_error() const

Description

Return the value of the flag in this raw_fd_ostream indicating whether an output error has been encountered. This doesn't implicitly flush any pending output. Also, it doesn't guarantee to detect all errors unless the stream has been closed.

Declared at: llvm/include/llvm/Support/raw_ostream.h:535

void inc_pos(uint64_t Delta)

Declared at: llvm/include/llvm/Support/raw_ostream.h:483

Parameters

uint64_t Delta

bool isRegularFile() const

Declared at: llvm/include/llvm/Support/raw_ostream.h:519

bool is_displayed() const

Description

This function determines if this stream is connected to a "tty" or "console" window. That is, the output would be displayed to the user rather than being put on a pipe or stored in a file.

Declared at: llvm/include/llvm/Support/raw_ostream.h:525

Expected<sys::fs::FileLocker> lock()

Description

Locks the underlying file. The function blocks the current thread until the lock become available or error occurs. Possible use of this function may be as follows:

Declared at: llvm/include/llvm/Support/raw_ostream.h:568

Returns

RAII object that releases the lock upon leaving the scope, if the locking was successful. Otherwise returns corresponding error code.

size_t preferred_buffer_size() const

Description

Determine an efficient buffer size.

Declared at: llvm/include/llvm/Support/raw_ostream.h:471

void pwrite_impl(const char* Ptr,
                 size_t Size,
                 uint64_t Offset)

Declared at: llvm/include/llvm/Support/raw_ostream.h:464

Parameters

const char* Ptr
size_t Size
uint64_t Offset

raw_fd_ostream(int fd,
               bool shouldClose,
               bool unbuffered = false,
               llvm::raw_ostream::OStreamKind K =
                   OStreamKind::OK_OStream)

Description

FD is the file descriptor that this writes to. If ShouldClose is true, this closes the file when the stream is destroyed. If FD is for stdout or stderr, it will not be closed.

Declared at: llvm/include/llvm/Support/raw_ostream.h:508

Parameters

int fd
bool shouldClose
bool unbuffered = false
llvm::raw_ostream::OStreamKind K = OStreamKind::OK_OStream

raw_fd_ostream(llvm::StringRef Filename,
               std::error_code& EC,
               sys::fs::CreationDisposition Disp,
               sys::fs::FileAccess Access,
               sys::fs::OpenFlags Flags)

Declared at: llvm/include/llvm/Support/raw_ostream.h:501

Parameters

llvm::StringRef Filename
std::error_code& EC
sys::fs::CreationDisposition Disp
sys::fs::FileAccess Access
sys::fs::OpenFlags Flags

raw_fd_ostream(llvm::StringRef Filename,
               std::error_code& EC,
               sys::fs::OpenFlags Flags)

Declared at: llvm/include/llvm/Support/raw_ostream.h:499

Parameters

llvm::StringRef Filename
std::error_code& EC
sys::fs::OpenFlags Flags

raw_fd_ostream(llvm::StringRef Filename,
               std::error_code& EC,
               sys::fs::FileAccess Access)

Declared at: llvm/include/llvm/Support/raw_ostream.h:497

Parameters

llvm::StringRef Filename
std::error_code& EC
sys::fs::FileAccess Access

raw_fd_ostream(llvm::StringRef Filename,
               std::error_code& EC,
               sys::fs::CreationDisposition Disp)

Declared at: llvm/include/llvm/Support/raw_ostream.h:495

Parameters

llvm::StringRef Filename
std::error_code& EC
sys::fs::CreationDisposition Disp

raw_fd_ostream(llvm::StringRef Filename,
               std::error_code& EC)

Description

Open the specified file for writing. If an error occurs, information about the error is put into EC, and the stream should be immediately destroyed;\p Flags allows optional flags to control how the file will be opened. As a special case, if Filename is "-", then the stream will use STDOUT_FILENO instead of opening a file. This will not close the stdout descriptor.

Declared at: llvm/include/llvm/Support/raw_ostream.h:494

Parameters

llvm::StringRef Filename
std::error_code& EC

uint64_t seek(uint64_t off)

Description

Flushes the stream and repositions the underlying file descriptor position to the offset specified from the beginning of the file.

Declared at: llvm/include/llvm/Support/raw_ostream.h:523

Parameters

uint64_t off

bool supportsSeeking() const

Declared at: llvm/include/llvm/Support/raw_ostream.h:517

Expected<sys::fs::FileLocker> tryLockFor(
    const llvm::Duration& Timeout)

Description

Tries to lock the underlying file within the specified period. It is used as @ref lock.

Declared at: llvm/include/llvm/Support/raw_ostream.h:578

Parameters

const llvm::Duration& Timeout

Returns

RAII object that releases the lock upon leaving the scope, if the locking was successful. Otherwise returns corresponding error code.

void write_impl(const char* Ptr, size_t Size)

Description

See raw_ostream::write_impl.

Declared at: llvm/include/llvm/Support/raw_ostream.h:462

Parameters

const char* Ptr
size_t Size

~raw_fd_ostream()

Declared at: llvm/include/llvm/Support/raw_ostream.h:511