libcommonc++  0.7
Dir Class Reference

Directory reading support. More...

#include <Dir.h++>

Public Member Functions

 Dir (const String &path)
 Construct a new Dir object for the given path. More...
 
 ~Dir ()
 Destructor. More...
 
void open (bool listHidden=false, bool listDot=false)
 Open the directory. More...
 
void close ()
 Close the directory. More...
 
void rewind ()
 Rewind the directory. More...
 
bool isOpen () const
 Test if the directory is currently open. More...
 
bool nextFile (String &name, FileAttributes &attrib, bool fetchPermissions=false)
 Retrieve the next file from the directory. More...
 

Detailed Description

Directory reading support.

The class provides a means of enumerating through the files in a directory.

Author
Mark Lindner

Constructor & Destructor Documentation

◆ Dir()

Dir ( const String path)

Construct a new Dir object for the given path.

Parameters
pathThe path to the directory.

◆ ~Dir()

~Dir ( )

Destructor.

Member Function Documentation

◆ close()

void close ( )

Close the directory.

If the directory is already closed, the method has no effect.

◆ isOpen()

bool isOpen ( ) const
inline

Test if the directory is currently open.

◆ nextFile()

bool nextFile ( String name,
FileAttributes attrib,
bool  fetchPermissions = false 
)

Retrieve the next file from the directory.

Parameters
nameThe String in which to place the file's name.
attribThe FileAttributes object in which to place the file's attributes.
fetchPermissionsA flag indicating whether the file permissions should be fetched for the file. This is a very slow operation on Windows, hence by default this option is disabled. On POSIX systems, this flag is ignored because fetching the file permissions has no overhead.
Returns
true if the information was successfully retrieved, false if the end of the directory has been reached.

◆ open()

void open ( bool  listHidden = false,
bool  listDot = false 
)

Open the directory.

If the directory is already open, the method has no effect.

Parameters
listHiddenA flag indicating whether hidden files (as defined for the host platform) should be listed or ignored.
listDotA flag indicating whether the files '.' and '..' should be listed or ignored.
Exceptions
IOExceptionIf the directory could not be opened.

◆ rewind()

void rewind ( )

Rewind the directory.

On some platforms this entails closing and re-opening the directory.

Exceptions
IOExceptionIf the directory could not be rewound.

The documentation for this class was generated from the following files: