Also use Objects as part of an operation but as a result don't generate Any operation...
[ACE_TAO.git] / ACE / ace / Dirent.inl
blob3e420f1cc7183db777a6561b14f44ef1c07b1f3f
1 // -*- C++ -*-
2 #include "ace/Log_Category.h"
4 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
6 ACE_INLINE int
7 ACE_Dirent::open (const ACE_TCHAR *dirname)
9   // If the directory stream is already open, close it to prevent
10   // possible resource leaks.
12   if (this->dirp_ != 0)
13     {
14       ACE_OS::closedir (this->dirp_);
15       this->dirp_ = 0;
16     }
18   this->dirp_ = ACE_OS::opendir (dirname);
20   if (this->dirp_ == 0)
21     return -1;
22   else
23     return 0;
26 ACE_INLINE
27 ACE_Dirent::ACE_Dirent (void)
28   : dirp_ (0)
32 ACE_INLINE
33 ACE_Dirent::ACE_Dirent (const ACE_TCHAR *dirname)
34   : dirp_ (0)
36   if (this->open (dirname) == -1)
37     ACELIB_ERROR ((LM_ERROR,
38                 ACE_TEXT ("%p\n"),
39                 ACE_TEXT ("ACE_Dirent::ACE_Dirent")));
42 ACE_INLINE
43 ACE_Dirent::~ACE_Dirent (void)
45   if (this->dirp_ != 0)
46     ACE_OS::closedir (this->dirp_);
49 ACE_INLINE ACE_DIRENT *
50 ACE_Dirent::read (void)
52   return this->dirp_ ? ACE_OS::readdir (this->dirp_) : 0;
55 ACE_INLINE int
56 ACE_Dirent::read (struct ACE_DIRENT *entry,
57                   struct ACE_DIRENT **result)
59   return this->dirp_
60          ? ACE_OS::readdir_r (this->dirp_, entry, result)
61          : 0;
64 ACE_INLINE void
65 ACE_Dirent::close (void)
67   if (this->dirp_ != 0)
68     {
69       ACE_OS::closedir (this->dirp_);
71       // Prevent double closure
72       this->dirp_ = 0;
73     }
76 ACE_INLINE void
77 ACE_Dirent::rewind (void)
79   if (this->dirp_)
80     ACE_OS::rewinddir (this->dirp_);
83 ACE_INLINE void
84 ACE_Dirent::seek (long loc)
86   if (this->dirp_)
87     ACE_OS::seekdir (this->dirp_, loc);
90 ACE_INLINE long
91 ACE_Dirent::tell (void)
93   return this->dirp_ ? ACE_OS::telldir (this->dirp_) : 0;
96 ACE_END_VERSIONED_NAMESPACE_DECL