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.
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
);
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
);
42 ACE_OS::free (this->namelist_
[n_
]->d_name
);
43 #endif /* ACE_HAS_ALLOC_HOOKS */
45 #if defined (ACE_HAS_ALLOC_HOOKS)
46 ACE_Allocator::instance()->free (this->namelist_
[n_
]);
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_
);
55 ACE_OS::free (this->namelist_
);
56 #endif /* ACE_HAS_ALLOC_HOOKS */
61 ACE_END_VERSIONED_NAMESPACE_DECL