MPD 0.20.6

- Main Page
- Namespaces
- Data Structures
- Files

- Data Structures
- Class Hierarchy
- Data Fields

Public Member Functions | Static Public Member Functions | Protected Attributes
FileDescriptor Class Reference

An OO wrapper for a UNIX file descriptor. More...

`#include <FileDescriptor.hxx>`

## Public Member Functions
| FileDescriptor ()=default
constexpr | FileDescriptor (int _fd)
constexpr bool | operator== (FileDescriptor other) const
constexpr bool | IsDefined () const
constexpr int | Get () const
| Returns the file descriptor. More...
void | Set (int _fd)
int | Steal ()
void | SetUndefined ()
bool | Open (const char *pathname, int flags, mode_t mode=0666)
bool | OpenReadOnly (const char *pathname)
bool | OpenNonBlocking (const char *pathname)
void | SetNonBlocking ()
| Enable non-blocking mode on this file descriptor. More...
void | SetBlocking ()
| Enable blocking mode on this file descriptor. More...
bool | Duplicate (int new_fd) const
| Duplicate the file descriptor onto the given file descriptor. More...
bool | Close ()
| Close the file descriptor. More...
bool | Rewind ()
| Rewind the pointer to the beginning of the file. More...
off_t | Seek (off_t offset)
off_t | Skip (off_t offset)
gcc_pure off_t | Tell () const
gcc_pure off_t | GetSize () const
| Returns the size of the file in bytes, or -1 on error. More...
ssize_t | Read (void *buffer, size_t length)
ssize_t | Write (const void *buffer, size_t length)
int | Poll (short events, int timeout) const
int | WaitReadable (int timeout) const
int | WaitWritable (int timeout) const

## Static Public Member Functions
static constexpr FileDescriptor | Undefined ()
static bool | CreatePipe (FileDescriptor &r, FileDescriptor &w)

## Protected Attributes
int | fd

## Detailed Description

An OO wrapper for a UNIX file descriptor.

This class is unmanaged and trivial.

Definition at line 49 of file FileDescriptor.hxx.

## Constructor & Destructor Documentation

FileDescriptor::FileDescriptor | ( |  | ) |
| default

constexpr FileDescriptor::FileDescriptor | ( | int | _fd | ) |
| inline explicit

Definition at line 55 of file FileDescriptor.hxx.

## Member Function Documentation

bool FileDescriptor::Close | ( |  | ) |
| inline

Close the file descriptor.

It is legal to call it on an "undefined" object. After this call, IsDefined() is guaranteed to return false, and this object may be reused.

Definition at line 136 of file FileDescriptor.hxx.

static bool FileDescriptor::CreatePipe | ( | FileDescriptor & | r,
|  | FileDescriptor & | w
| ) |  |
| static

bool FileDescriptor::Duplicate | ( | int | new_fd | ) | const
| inline

Duplicate the file descriptor onto the given file descriptor.

Definition at line 114 of file FileDescriptor.hxx.

constexpr int FileDescriptor::Get | ( |  | ) | const
| inline

Returns the file descriptor.

This may only be called if IsDefined() returns true.

Definition at line 69 of file FileDescriptor.hxx.

gcc_pure off_t FileDescriptor::GetSize | ( |  | ) | const

Returns the size of the file in bytes, or -1 on error.

constexpr bool FileDescriptor::IsDefined | ( |  | ) | const
| inline

Definition at line 61 of file FileDescriptor.hxx.

bool FileDescriptor::Open | ( | const char * | pathname,
|  | int | flags,
|  | mode_t | mode = `0666`
| ) |  |

bool FileDescriptor::OpenNonBlocking | ( | const char * | pathname | ) |

bool FileDescriptor::OpenReadOnly | ( | const char * | pathname | ) |

constexpr bool FileDescriptor::operator== | ( | FileDescriptor | other | ) | const
| inline

Definition at line 57 of file FileDescriptor.hxx.

int FileDescriptor::Poll | ( | short | events,
|  | int | timeout
| ) |  | const

ssize_t FileDescriptor::Read | ( | void * | buffer,
|  | size_t | length
| ) |  |
| inline

Definition at line 164 of file FileDescriptor.hxx.

bool FileDescriptor::Rewind | ( |  | ) |

Rewind the pointer to the beginning of the file.

off_t FileDescriptor::Seek | ( | off_t | offset | ) |
| inline

Definition at line 145 of file FileDescriptor.hxx.

void FileDescriptor::Set | ( | int | _fd | ) |
| inline

Definition at line 73 of file FileDescriptor.hxx.

void FileDescriptor::SetBlocking | ( |  | ) |

Enable blocking mode on this file descriptor.

void FileDescriptor::SetNonBlocking | ( |  | ) |

Enable non-blocking mode on this file descriptor.

void FileDescriptor::SetUndefined | ( |  | ) |
| inline

Definition at line 85 of file FileDescriptor.hxx.

off_t FileDescriptor::Skip | ( | off_t | offset | ) |
| inline

Definition at line 149 of file FileDescriptor.hxx.

int FileDescriptor::Steal | ( |  | ) |
| inline

Definition at line 77 of file FileDescriptor.hxx.

gcc_pure off_t FileDescriptor::Tell | ( |  | ) | const
| inline

Definition at line 154 of file FileDescriptor.hxx.

static constexpr FileDescriptor FileDescriptor::Undefined | ( |  | ) |
| inline static

Definition at line 89 of file FileDescriptor.hxx.

int FileDescriptor::WaitReadable | ( | int | timeout | ) | const

int FileDescriptor::WaitWritable | ( | int | timeout | ) | const

ssize_t FileDescriptor::Write | ( | const void * | buffer,
|  | size_t | length
| ) |  |
| inline

Definition at line 168 of file FileDescriptor.hxx.

## Field Documentation

int FileDescriptor::fd
| protected

Definition at line 51 of file FileDescriptor.hxx.

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

- system/FileDescriptor.hxx