libzypp  13.10.6
Fd.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifndef ZYPP_BASE_FD_H
13 #define ZYPP_BASE_FD_H
14 
15 #include "zypp/Pathname.h"
16 
18 namespace zypp
19 {
20  namespace base
22  {
23 
25  //
26  // CLASS NAME : Fd
27  //
44  class Fd
45  {
46  public:
50  Fd( const Pathname & file_r, int open_flags, mode_t mode = 0 );
51 
53  ~Fd()
54  { close(); }
55 
57  void close();
58 
60  bool isOpen() const
61  { return m_fd != -1; }
62 
64  int fd() const
65  { return m_fd; }
66 
67  private:
69  int m_fd;
71  Fd( const Fd & );
73  Fd & operator=( const Fd & );
74  };
76 
78  } // namespace base
81 } // namespace zypp
83 #endif // ZYPP_BASE_FD_H
Fd & operator=(const Fd &)
No assign.
void close()
Explicitly close the file.
Definition: Fd.cc:49
int m_fd
The filedescriptor.
Definition: Fd.h:69
bool isOpen() const
Test for valid filedescriptor.
Definition: Fd.h:60
Fd(const Pathname &file_r, int open_flags, mode_t mode=0)
Ctor opens file.
Definition: Fd.cc:36
Assert close called on open filedescriptor.
Definition: Fd.h:44
int fd() const
Return the filedescriptor.
Definition: Fd.h:64
~Fd()
Dtor closes file.
Definition: Fd.h:53