Fd.cc

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
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     //  METHOD NAME : Fd::Fd
00032     //  METHOD TYPE : Ctor
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     //  METHOD NAME : Fd::close
00045     //  METHOD TYPE : void
00046     //
00047     void Fd::close()
00048     {
00049       if ( m_fd != -1 )
00050         {
00051           ::close( m_fd );
00052           m_fd = -1;
00053         }
00054     }
00055 
00057   } // namespace base
00060 } // namespace zypp

Generated on Thu Jul 6 00:07:20 2006 for zypp by  doxygen 1.4.6