Fd.cc
Go to the documentation of this file.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 <iostream>
00020
00021 #include "zypp/base/Exception.h"
00022 #include "zypp/base/Fd.h"
00023
00025 namespace zypp
00026 {
00027
00028 namespace base
00029 {
00030
00032
00033
00034
00035
00036 Fd::Fd( const Pathname & file_r, int open_flags, mode_t mode )
00037 : m_fd( -1 )
00038 {
00039 m_fd = open( file_r.asString().c_str(), open_flags, mode );
00040 if ( m_fd == -1 )
00041 ZYPP_THROW_ERRNO_MSG( Exception, std::string("open ")+file_r.asString() );
00042 }
00043
00045
00046
00047
00048
00049 void Fd::close()
00050 {
00051 if ( m_fd != -1 )
00052 {
00053 ::close( m_fd );
00054 m_fd = -1;
00055 }
00056 }
00057
00059 }
00062 }