1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/base/Fd.h
12 #ifndef ZYPP_BASE_FD_H
13 #define ZYPP_BASE_FD_H
15 #include "zypp/Pathname.h"
17 ///////////////////////////////////////////////////////////////////
19 { /////////////////////////////////////////////////////////////////
20 ///////////////////////////////////////////////////////////////////
22 { /////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////
28 /** Assert \c close called on open filedescriptor.
31 * scoped_ptr<Fd> fd; // calls close when going out of scope
33 * fd.reset( new Fd( "/some/file" ) );
37 * read( fd->fd(), ... ),
41 * \todo It's dumb. Openflags and more related functions (read/write..)
49 * \throw EXCEPTION If open fails.
51 Fd( const Pathname & file_r, int open_flags, mode_t mode = 0 );
56 { std::swap( m_fd, rhs.m_fd ); }
59 Fd & operator=( Fd && rhs )
60 { if ( this != &rhs ) std::swap( m_fd, rhs.m_fd ); return *this; }
62 /** Dtor closes file. */
66 /** Explicitly close the file. */
69 /** Test for valid filedescriptor. */
71 { return m_fd != -1; }
73 /** Return the filedescriptor. */
77 /** Return the filedescriptor. */
82 /** The filedescriptor. */
85 ///////////////////////////////////////////////////////////////////
87 /////////////////////////////////////////////////////////////////
89 ///////////////////////////////////////////////////////////////////
90 /////////////////////////////////////////////////////////////////
92 ///////////////////////////////////////////////////////////////////
93 #endif // ZYPP_BASE_FD_H