Документ взят из кэша поисковой машины. Адрес
оригинального документа
: http://www.atnf.csiro.au/computing/software/casacore/casacore-1.2.0/doc/html/classcasa_1_1DirectoryIterator.html
Дата изменения: Unknown Дата индексирования: Mon Feb 14 22:56:12 2011 Кодировка: Поисковые слова: п п п п п п п р п р п р п р п р п р п р п |
Traverse the contents of a directory. More...
#include <DirectoryIterator.h>
Public Member Functions | |
DirectoryIterator () | |
Construct the iterator for the working directory. | |
DirectoryIterator (const Directory &dir) | |
Construct the iterator for the given directory. | |
DirectoryIterator (const Directory &dir, const Regex ®Expression) | |
Construct the iterator for the given directory. | |
DirectoryIterator (const DirectoryIterator &that) | |
Copy constructor (copy semantics). | |
DirectoryIterator & | operator= (const DirectoryIterator &that) |
Assignment (copy semantics). | |
~DirectoryIterator () | |
void | operator++ () |
Position on the next matching entry in the directory. | |
void | operator++ (int) |
String | name () const |
Returns the file name at the current position. | |
File | file () const |
Returns a File object for the file at the current position. | |
void | reset () |
Reposition the directory stream on the first entry. | |
Bool | pastEnd () const |
Checks if the iterator is past the end. | |
Private Member Functions | |
void | init () |
Initialize the iterator. | |
Private Attributes | |
DIR * | itsDirectoryDescriptor |
This variable is used for seeking in the directory. | |
dirent * | itsDirectoryEntry |
This structure is used for information of the directory. | |
Bool | itsEnd |
Boolean to check if the directory stream has past the end. | |
Directory | itsDirectory |
class directory | |
Regex | itsExpression |
Regular expression if given, with this variable it is possible to compare files with regular expression. | |
dirent ** | itsNameList |
Cray XT3 does not support readdir on compute nodes. | |
int | itsNrNames |
int | itsNameInx |
Traverse the contents of a directory.
Public interface
DirectoryIterator allows to traverse a directory. In this way all file names in a directory can be gotten. Files . and .. will always be skipped.
By means of a regular expression it is possible to traverse the directory selectively. That is, only the file names matching the regular expression will be returned. Note that the regular expression is a true regular expression (as defined by class Regex and not a file expression as used in shells. Thus to get all .cc files, one has to specify ".*\.cc" and not "*.cc".
The File class can be used to determine if a file represents a symlink, directory or regular file.
Directory dir("testdir"); // Get all .cc files. // Note that Regex is a true regular expression and not a // simplified file expression (like *.cc) as used in shells. DirectoryIterator dirIter(dir, ".*.\cc"); while (!dirIter.pastEnd()){ cout << dirIter.name() << endl; dirIter++; }
With this class it is easy to iterate through a directory.
Definition at line 91 of file DirectoryIterator.h.
casa::DirectoryIterator::DirectoryIterator | ( | ) |
Construct the iterator for the working directory.
All entries (except . and ..) will be traversed. It positions the iterator on the first entry.
casa::DirectoryIterator::DirectoryIterator | ( | const Directory & | dir | ) |
Construct the iterator for the given directory.
All entries (except . and ..) will be traversed. It positions the iterator on the first entry.
Construct the iterator for the given directory.
All entries matching the regular expression will be traversed. It positions the iterator on the first entry.
casa::DirectoryIterator::DirectoryIterator | ( | const DirectoryIterator & | that | ) |
Copy constructor (copy semantics).
The iterator will be positioned at the beginning.
casa::DirectoryIterator::~DirectoryIterator | ( | ) |
File casa::DirectoryIterator::file | ( | ) | const |
Returns a File object for the file at the current position.
Note that this adds the path of the directory to get the correct path for the file.
An exception is thrown if the iterator is already past the end.
void casa::DirectoryIterator::init | ( | ) | [private] |
Initialize the iterator.
String casa::DirectoryIterator::name | ( | ) | const |
Returns the file name at the current position.
An exception is thrown if the iterator is already past the end.
void casa::DirectoryIterator::operator++ | ( | ) |
Position on the next matching entry in the directory.
An exception is thrown if the iterator is already past the end.
void casa::DirectoryIterator::operator++ | ( | int | ) |
DirectoryIterator& casa::DirectoryIterator::operator= | ( | const DirectoryIterator & | that | ) |
Assignment (copy semantics).
The iterator will be positioned at the beginning.
Bool casa::DirectoryIterator::pastEnd | ( | ) | const |
Checks if the iterator is past the end.
void casa::DirectoryIterator::reset | ( | ) |
Reposition the directory stream on the first entry.
class directory
Definition at line 102 of file DirectoryIterator.h.
DIR* casa::DirectoryIterator::itsDirectoryDescriptor [private] |
This variable is used for seeking in the directory.
The directory is opened and closed once during the lifetime of the class.
Definition at line 93 of file DirectoryIterator.h.
dirent* casa::DirectoryIterator::itsDirectoryEntry [private] |
This structure is used for information of the directory.
Definition at line 96 of file DirectoryIterator.h.
Bool casa::DirectoryIterator::itsEnd [private] |
Boolean to check if the directory stream has past the end.
Definition at line 99 of file DirectoryIterator.h.
Regex casa::DirectoryIterator::itsExpression [private] |
Regular expression if given, with this variable it is possible to compare files with regular expression.
Definition at line 106 of file DirectoryIterator.h.
int casa::DirectoryIterator::itsNameInx [private] |
Definition at line 112 of file DirectoryIterator.h.
dirent** casa::DirectoryIterator::itsNameList [private] |
Cray XT3 does not support readdir on compute nodes.
Use scandir instead.
Definition at line 110 of file DirectoryIterator.h.
int casa::DirectoryIterator::itsNrNames [private] |
Definition at line 111 of file DirectoryIterator.h.