libzypp  13.10.6
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 ()
 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...
 

Private Member Functions

 Fd (const Fd &)
 No copy. More...
 
Fdoperator= (const Fd &)
 No assign. More...
 

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(), ... ),
*
Todo:
It's dumb. Openflags and more related functions (read/write..) could be added.

Definition at line 44 of file Fd.h.

Constructor & Destructor Documentation

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

Ctor opens file.

Exceptions
EXCEPTIONIf open fails.

Definition at line 36 of file Fd.cc.

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

Dtor closes file.

Definition at line 53 of file Fd.h.

zypp::base::Fd::Fd ( const Fd )
private

No copy.

Member Function Documentation

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

Explicitly close the file.

Definition at line 49 of file Fd.cc.

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

Test for valid filedescriptor.

Definition at line 60 of file Fd.h.

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

Return the filedescriptor.

Definition at line 64 of file Fd.h.

Fd& zypp::base::Fd::operator= ( const Fd )
private

No assign.

Member Data Documentation

int zypp::base::Fd::m_fd
private

The filedescriptor.

Definition at line 69 of file Fd.h.


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