00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file Dirent_Selector.h 00006 * 00007 * $Id: Dirent_Selector.h 80826 2008-03-04 14:51:23Z wotte $ 00008 * 00009 * Define a portable C++ interface to the <ACE_OS_Dirent::scandir> method. 00010 * 00011 * @author Rich Newman <RNewman@directv.com> 00012 */ 00013 //============================================================================= 00014 00015 #ifndef ACE_DIRENT_SELECTOR_H 00016 #define ACE_DIRENT_SELECTOR_H 00017 #include /**/ "ace/pre.h" 00018 00019 #include /**/ "ace/ACE_export.h" 00020 00021 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00022 #pragma once 00023 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00024 00025 #include "ace/OS_NS_dirent.h" /* Need ACE_SCANDIR_SELECTOR, COMPARATOR */ 00026 #include "ace/os_include/os_dirent.h" 00027 00028 ACE_BEGIN_VERSIONED_NAMESPACE_DECL 00029 00030 /** 00031 * @class ACE_Dirent_Selector 00032 * 00033 * @brief Define a portable C++ directory-entry iterator based on the 00034 * POSIX scandir API. 00035 */ 00036 class ACE_Export ACE_Dirent_Selector 00037 { 00038 public: 00039 /// Constructor 00040 ACE_Dirent_Selector (void); 00041 00042 /// Destructor. 00043 virtual ~ACE_Dirent_Selector (void); 00044 00045 /// Return the length of the list of matching directory entries. 00046 int length (void) const; 00047 00048 /// Return the entry at @a index. 00049 ACE_DIRENT *operator[] (const int index) const; 00050 00051 /// Free up resources. 00052 int close (void); 00053 00054 /// Open the directory @a dir and populate the current list of names with 00055 /// directory entries that match the @a selector and @a comparator. 00056 int open (const ACE_TCHAR *dir, 00057 ACE_SCANDIR_SELECTOR selector = 0, 00058 ACE_SCANDIR_COMPARATOR comparator = 0); 00059 00060 protected: 00061 /// Ptr to the namelist array. 00062 ACE_DIRENT **namelist_; 00063 00064 /// Number of entries in the array. 00065 int n_; 00066 }; 00067 00068 ACE_END_VERSIONED_NAMESPACE_DECL 00069 00070 #if defined (__ACE_INLINE__) 00071 #include "ace/Dirent_Selector.inl" 00072 #endif /* __ACE_INLINE__ */ 00073 00074 #include /**/ "ace/post.h" 00075 #endif /* ACE_DIRENT_SELECTOR_H */