00001
00002
00003
00004
00005
00006
00007
00008
00012 extern "C"
00013 {
00014 #include <sys/types.h>
00015 #include <sys/stat.h>
00016 #include <fcntl.h>
00017 }
00018
00019 #include "zypp/base/Exception.h"
00020 #include "zypp/base/Fd.h"
00021
00023 namespace zypp
00024 {
00025
00026 namespace base
00027 {
00028
00030
00031
00032
00033
00034 Fd::Fd( const Pathname & file_r, int open_flags )
00035 : m_fd( -1 )
00036 {
00037 m_fd = open( file_r.asString().c_str(), open_flags );
00038 if ( m_fd == -1 )
00039 ZYPP_THROW_ERRNO_MSG( Exception, std::string("open ")+file_r.asString() );
00040 }
00041
00043
00044
00045
00046
00047 void Fd::close()
00048 {
00049 if ( m_fd != -1 )
00050 {
00051 ::close( m_fd );
00052 m_fd = -1;
00053 }
00054 }
00055
00057 }
00060 }