Dirent.inl

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Dirent.inl,v 4.3 2006/02/10 10:05:09 jwillemsen Exp
00004 
00005 #include "ace/Log_Msg.h"
00006 
00007 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00008 
00009 ACE_INLINE int
00010 ACE_Dirent::open (const ACE_TCHAR *dirname)
00011 {
00012   // If the directory stream is already open, close it to prevent
00013   // possible resource leaks.
00014 
00015   if (this->dirp_ != 0)
00016     {
00017       ACE_OS::closedir (this->dirp_);
00018       this->dirp_ = 0;
00019     }
00020 
00021   this->dirp_ = ACE_OS::opendir (dirname);
00022 
00023   if (this->dirp_ == 0)
00024     return -1;
00025   else
00026     return 0;
00027 }
00028 
00029 ACE_INLINE
00030 ACE_Dirent::ACE_Dirent (void)
00031   : dirp_ (0)
00032 {
00033 }
00034 
00035 ACE_INLINE
00036 ACE_Dirent::ACE_Dirent (const ACE_TCHAR *dirname)
00037   : dirp_ (0)
00038 {
00039   if (this->open (dirname) == -1)
00040     ACE_ERROR ((LM_ERROR,
00041                 ACE_LIB_TEXT ("%p\n"),
00042                 ACE_LIB_TEXT ("ACE_Dirent::ACE_Dirent")));
00043 }
00044 
00045 ACE_INLINE
00046 ACE_Dirent::~ACE_Dirent (void)
00047 {
00048   if (this->dirp_ != 0)
00049     ACE_OS::closedir (this->dirp_);
00050 }
00051 
00052 ACE_INLINE ACE_DIRENT *
00053 ACE_Dirent::read (void)
00054 {
00055   return this->dirp_ ? ACE_OS::readdir (this->dirp_) : 0;
00056 }
00057 
00058 ACE_INLINE int
00059 ACE_Dirent::read (struct ACE_DIRENT *entry,
00060                   struct ACE_DIRENT **result)
00061 {
00062   return this->dirp_
00063          ? ACE_OS::readdir_r (this->dirp_, entry, result)
00064          : 0;
00065 }
00066 
00067 ACE_INLINE void
00068 ACE_Dirent::close (void)
00069 {
00070   if (this->dirp_ != 0)
00071     {
00072       ACE_OS::closedir (this->dirp_);
00073 
00074       // Prevent double closure
00075       this->dirp_ = 0;
00076     }
00077 }
00078 
00079 ACE_INLINE void
00080 ACE_Dirent::rewind (void)
00081 {
00082   if (this->dirp_)
00083     ACE_OS::rewinddir (this->dirp_);
00084 }
00085 
00086 ACE_INLINE void
00087 ACE_Dirent::seek (long loc)
00088 {
00089   if (this->dirp_)
00090     ACE_OS::seekdir (this->dirp_, loc);
00091 }
00092 
00093 ACE_INLINE long
00094 ACE_Dirent::tell (void)
00095 {
00096   return this->dirp_ ? ACE_OS::telldir (this->dirp_) : 0;
00097 }
00098 
00099 ACE_END_VERSIONED_NAMESPACE_DECL

Generated on Thu Nov 9 09:41:50 2006 for ACE by doxygen 1.3.6