libzypp  17.11.0
zypp::base::Fd Class Reference

Assert close called on open filedescriptor. More...

#include <Fd.h>

Public Member Functions

 Fd (const Pathname &file_r, int open_flags, mode_t mode=0)
 Ctor opens file. More...
 Fd (Fd &&rhs)
 Move ctor. More...
Fdoperator= (Fd &&rhs)
 Move assign. More...
 ~Fd ()
 Dtor closes file. More...
void close ()
 Explicitly close the file. More...
bool isOpen () const
 Test for valid filedescriptor. More...
int fd () const
 Return the filedescriptor. More...
int operator* () const
 Return the filedescriptor. More...

Private Member Functions


Private Attributes

int m_fd
 The filedescriptor. More...

Detailed Description

Assert close called on open filedescriptor.

scoped_ptr<Fd> fd; // calls close when going out of scope
try {
fd.reset( new Fd( "/some/file" ) );
} catch ( ... ) {
// open failed.
read( fd->fd(), ... ),
It's dumb. Openflags and more related functions (read/write..) could be added.

Definition at line 44 of file Fd.h.

Constructor & Destructor Documentation

◆ Fd() [1/2]

zypp::base::Fd::Fd ( const Pathname file_r,
int  open_flags,
mode_t  mode = 0 

Ctor opens file.

EXCEPTIONIf open fails.

Definition at line 36 of file

◆ Fd() [2/2]

zypp::base::Fd::Fd ( Fd &&  rhs)

Move ctor.

Definition at line 54 of file Fd.h.

◆ ~Fd()

zypp::base::Fd::~Fd ( )

Dtor closes file.

Definition at line 63 of file Fd.h.

Member Function Documentation


zypp::base::Fd::NON_COPYABLE ( Fd  )

◆ operator=()

Fd& zypp::base::Fd::operator= ( Fd &&  rhs)

Move assign.

Definition at line 59 of file Fd.h.

◆ close()

void zypp::base::Fd::close ( )

Explicitly close the file.

Definition at line 49 of file

◆ isOpen()

bool zypp::base::Fd::isOpen ( ) const

Test for valid filedescriptor.

Definition at line 70 of file Fd.h.

◆ fd()

int zypp::base::Fd::fd ( ) const

Return the filedescriptor.

Definition at line 74 of file Fd.h.

◆ operator*()

int zypp::base::Fd::operator* ( ) const

Return the filedescriptor.

Definition at line 78 of file Fd.h.

Member Data Documentation

◆ m_fd

int zypp::base::Fd::m_fd

The filedescriptor.

Definition at line 83 of file Fd.h.

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