Document return values
[ACE_TAO.git] / ACE / ace / Dirent_Selector.cpp
blob7591b0b00d4d0f07283e46c69ced39afcd831dcd
1 #include "ace/Dirent_Selector.h"
3 #if !defined (__ACE_INLINE__)
4 #include "ace/Dirent_Selector.inl"
5 #endif /* __ACE_INLINE__ */
7 #include "ace/OS_NS_dirent.h"
8 #include "ace/OS_NS_stdlib.h"
10 #if defined (ACE_HAS_ALLOC_HOOKS)
11 # include "ace/Malloc_Base.h"
12 #endif /* ACE_HAS_ALLOC_HOOKS */
14 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
16 ACE_Dirent_Selector::~ACE_Dirent_Selector ()
18 // Free up any allocated resources.
19 this->close();
22 int
23 ACE_Dirent_Selector::open (const ACE_TCHAR *dir,
24 ACE_SCANDIR_SELECTOR sel,
25 ACE_SCANDIR_COMPARATOR cmp)
27 n_ = ACE_OS::scandir (dir, &this->namelist_, sel, cmp);
28 return n_;
31 int
32 ACE_Dirent_Selector::close ()
34 for (--n_; n_ >= 0; --n_)
36 #if defined (ACE_LACKS_STRUCT_DIR)
37 // Only the lacking-struct-dir emulation allocates this. Native
38 // scandir includes d_name in the dirent struct itself.
39 #if defined (ACE_HAS_ALLOC_HOOKS)
40 ACE_Allocator::instance()->free (this->namelist_[n_]->d_name);
41 #else
42 ACE_OS::free (this->namelist_[n_]->d_name);
43 #endif /* ACE_HAS_ALLOC_HOOKS */
44 #endif
45 #if defined (ACE_HAS_ALLOC_HOOKS)
46 ACE_Allocator::instance()->free (this->namelist_[n_]);
47 #else
48 ACE_OS::free (this->namelist_[n_]);
49 #endif /* ACE_HAS_ALLOC_HOOKS */
52 #if defined (ACE_HAS_ALLOC_HOOKS)
53 ACE_Allocator::instance()->free (this->namelist_);
54 #else
55 ACE_OS::free (this->namelist_);
56 #endif /* ACE_HAS_ALLOC_HOOKS */
57 this->namelist_ = 0;
58 return 0;
61 ACE_END_VERSIONED_NAMESPACE_DECL