Define a portable C++ directory-entry iterator based on the POSIX scandir API. More...
#include <Dirent_Selector.h>
Public Member Functions | |
| ACE_Dirent_Selector (void) | |
| Constructor. | |
| virtual | ~ACE_Dirent_Selector (void) |
| Destructor. | |
| int | length (void) const |
| Return the length of the list of matching directory entries. | |
| ACE_DIRENT * | operator[] (const int index) const |
| Return the entry at index. | |
| int | close (void) |
| Free up resources. | |
| int | open (const ACE_TCHAR *dir, ACE_SCANDIR_SELECTOR selector=0, ACE_SCANDIR_COMPARATOR comparator=0) |
Protected Attributes | |
| ACE_DIRENT ** | namelist_ |
| Ptr to the namelist array. | |
| int | n_ |
| Number of entries in the array. | |
Define a portable C++ directory-entry iterator based on the POSIX scandir API.
Definition at line 36 of file Dirent_Selector.h.
| ACE_Dirent_Selector::ACE_Dirent_Selector | ( | void | ) |
Constructor.
| ACE_Dirent_Selector::~ACE_Dirent_Selector | ( | void | ) | [virtual] |
Destructor.
Definition at line 26 of file Dirent_Selector.cpp.
{
// Free up any allocated resources.
this->close();
}
| int ACE_Dirent_Selector::close | ( | void | ) |
Free up resources.
Definition at line 42 of file Dirent_Selector.cpp.
{
for (--n_; n_ >= 0; --n_)
{
#if defined (ACE_LACKS_STRUCT_DIR)
// Only the lacking-struct-dir emulation allocates this. Native
// scandir includes d_name in the dirent struct itself.
ACE_OS::free (this->namelist_[n_]->d_name);
#endif
ACE_OS::free (this->namelist_[n_]);
}
ACE_OS::free (this->namelist_);
this->namelist_ = 0;
return 0;
}
| int ACE_Dirent_Selector::length | ( | void | ) | const [inline] |
Return the length of the list of matching directory entries.
Definition at line 8 of file Dirent_Selector.inl.
{
return n_;
}
| int ACE_Dirent_Selector::open | ( | const ACE_TCHAR * | dir, | |
| ACE_SCANDIR_SELECTOR | selector = 0, |
|||
| ACE_SCANDIR_COMPARATOR | comparator = 0 | |||
| ) |
Open the directory dir and populate the current list of names with directory entries that match the selector and comparator.
Definition at line 33 of file Dirent_Selector.cpp.
{
n_ = ACE_OS::scandir (dir, &this->namelist_, sel, cmp);
return n_;
}
| ACE_DIRENT * ACE_Dirent_Selector::operator[] | ( | const int | index | ) | const [inline] |
Return the entry at index.
Definition at line 14 of file Dirent_Selector.inl.
{
return this->namelist_[n];
}
int ACE_Dirent_Selector::n_ [protected] |
Number of entries in the array.
Definition at line 65 of file Dirent_Selector.h.
ACE_DIRENT** ACE_Dirent_Selector::namelist_ [protected] |
Ptr to the namelist array.
Definition at line 62 of file Dirent_Selector.h.
1.7.0