summaryrefslogtreecommitdiff
path: root/ace/Dirent_Selector.cpp
blob: dce8d7f05ef8590bb07fb41c79b0164b3d78a03b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// $Id$

#include "ace/OS.h"
#include "ace/Dirent_Selector.h"

// Construction/Destruction

ACE_Dirent_Selector::ACE_Dirent_Selector (void) 
  : n_ (0),
    namelist_ (0)
{
}

ACE_Dirent_Selector::~ACE_Dirent_Selector (void)
{
}

int
ACE_Dirent_Selector::open (const ACE_TCHAR *dir,
                           int (*sel)(const dirent *d),
                           int (*cmp) (const dirent **d1,
                                       const dirent **d2))
{
  n_ = ACE_OS::scandir (dir, &this->namelist_, sel, cmp);
  return n_;
}

int
ACE_Dirent_Selector::close (void)
{
  for (--n_; n_>=0; --n_) 
    ACE_OS::free (this->namelist_[n_]);

  ACE_OS::free (this->namelist_);
  return 0;
}