libzypp
17.7.0
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
NON_COPYABLE
(
Fd
);
47
public
:
51
Fd
(
const
Pathname
& file_r,
int
open_flags, mode_t mode = 0 );
52
54
Fd
(
Fd
&& rhs )
55
:
m_fd
( -1 )
56
{ std::swap(
m_fd
, rhs.m_fd ); }
57
59
Fd
&
operator=
(
Fd
&& rhs )
60
{
if
(
this
!= &rhs ) std::swap(
m_fd
, rhs.m_fd );
return
*
this
; }
61
63
~Fd
()
64
{
close
(); }
65
67
void
close
();
68
70
bool
isOpen
()
const
71
{
return
m_fd
!= -1; }
72
74
int
fd
()
const
75
{
return
m_fd
; }
76
78
int
operator*
()
const
79
{
return
m_fd
; }
80
81
private
:
83
int
m_fd
;
84
};
86
88
}
// namespace base
91
}
// namespace zypp
93
#endif // ZYPP_BASE_FD_H
zypp::base::Fd::isOpen
bool isOpen() const
Test for valid filedescriptor.
Definition:
Fd.h:70
zypp::base::Fd::operator=
Fd & operator=(Fd &&rhs)
Move assign.
Definition:
Fd.h:59
zypp::base::Fd::m_fd
int m_fd
The filedescriptor.
Definition:
Fd.h:83
Pathname.h
zypp::base::Fd
Assert close called on open filedescriptor.
Definition:
Fd.h:44
zypp::base::Fd::fd
int fd() const
Return the filedescriptor.
Definition:
Fd.h:74
zypp::base::Fd::NON_COPYABLE
NON_COPYABLE(Fd)
zypp::base::Fd::close
void close()
Explicitly close the file.
Definition:
Fd.cc:49
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition:
CodePitfalls.doc:1
zypp::base::Fd::Fd
Fd(Fd &&rhs)
Move ctor.
Definition:
Fd.h:54
zypp::base::Fd::operator*
int operator*() const
Return the filedescriptor.
Definition:
Fd.h:78
zypp::filesystem::Pathname
Pathname.
Definition:
Pathname.h:43
zypp::base::Fd::~Fd
~Fd()
Dtor closes file.
Definition:
Fd.h:63
zypp::base::Fd::Fd
Fd(const Pathname &file_r, int open_flags, mode_t mode=0)
Ctor opens file.
Definition:
Fd.cc:36
zypp
base
Fd.h
Generated by
1.8.17