summaryrefslogtreecommitdiff
path: root/ace/Dirent_Selector.h
blob: 8270b0be399945efdee6263f71c6b603fc24a68d (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/* -*- C++ -*- */

//=============================================================================
/**
 *  @file    Dirent_Selector.h
 *
 *  $Id$
 *
 *  Define a portable C++ interface to the <ACE_OS_Dirent::scandir> method.
 *
 *  @author Rich Newman <RNewman@directv.com>
 */
//=============================================================================

#ifndef ACE_DIRENT_SELECTOR_H
#define ACE_DIRENT_SELECTOR_H
#include "ace/pre.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
#pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

#include "ace/ACE_export.h"

/**
 * @class ACE_Dirent_Selector
 *
 * @brief Define a portable C++ directory-entry iterator based on the
 * POSIX @param scandir API.
 */
class ACE_Export ACE_Dirent_Selector
{
public:
  /// Constructor
  ACE_Dirent_Selector (void);

  /// Destructor.
  virtual ~ACE_Dirent_Selector (void);

  /// Return the length of the list of matching directory entries.
  int length (void) const;

  /// Return the entry at <index>.
  dirent *operator[] (const int index) const;

  /// Free up resources.
  int close (void);

  /// Open the director <dir> and populate the <namelist_> array with
  /// directory entries that match the <selector> and <comparator>.
  int open (const ACE_TCHAR *dir,
            int (*selector)(const dirent *d) = 0,
            int (*comparator)(const dirent **d1, const dirent **d2) = 0);

protected:
  /// Ptr to the namelist array.
  dirent **namelist_;

  /// # of entries in the array.
  int n_;
};

#if defined (__ACE_INLINE__)
#include "ace/Dirent_Selector.inl"
#endif /* __ACE_INLINE__ */

#include "ace/post.h"
#endif /* ACE_DIRENT_SELECTOR_H */