Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Dirent.i

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

Generated on Mon Jun 16 11:19:36 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002