ClanLib  2.3.7
List of all members
CL_DirectoryScanner Class Reference

Directory scanning class. More...

#include <directory_scanner.h>

Public Member Functions

Construction
 CL_DirectoryScanner ()
 Constructs directory scanner for iterating over a directory. More...
 
 ~CL_DirectoryScanner ()
 Destructor. More...
 
Attributes
CL_String get_directory_path ()
 Gets the directory being scanned. More...
 
CL_String get_name ()
 Gets the name of the current file. More...
 
int get_size ()
 Gets the size of the current file. More...
 
CL_String get_pathname ()
 Gets the pathname of the current file. More...
 
bool is_directory ()
 Returns true if the current file is a directory. More...
 
bool is_hidden ()
 Returns true if the file is hidden. More...
 
bool is_readable ()
 Returns true if the file is readable by the current user. More...
 
bool is_writable ()
 Returns true if the file is writable by the current user. More...
 
Operations
bool scan (const CL_String &pathname)
 Selects the directory to scan through. More...
 
bool scan (const CL_String &pathname, const CL_String &pattern)
 Selects the directory to scan through. More...
 
bool next ()
 Find next file in directory scan. More...
 

Detailed Description

Directory scanning class.

CL_DirectoryScanner is used to parse through directory trees and return information about files.

Example that prints all files and directories found in the root directory:

   CL_DirectoryScanner scanner;
   if (scanner.scan("/", "*"))
   {
                while (scanner.next())
                {
                                cl_console_write_line(scanner.get_name());
                }
   }
   

Constructor & Destructor Documentation

CL_DirectoryScanner::CL_DirectoryScanner ( )

Constructs directory scanner for iterating over a directory.

CL_DirectoryScanner::~CL_DirectoryScanner ( )

Destructor.

Member Function Documentation

CL_String CL_DirectoryScanner::get_directory_path ( )

Gets the directory being scanned.

Returns
Directory being scanned. (including the trailing slash)
CL_String CL_DirectoryScanner::get_name ( )

Gets the name of the current file.

Returns
The name of the current found file.
CL_String CL_DirectoryScanner::get_pathname ( )

Gets the pathname of the current file.

Returns
The name of the current found file, including the directory path.
int CL_DirectoryScanner::get_size ( )

Gets the size of the current file.

Returns
The size of the current found file.
bool CL_DirectoryScanner::is_directory ( )

Returns true if the current file is a directory.

Returns
True if filename is a directory.
bool CL_DirectoryScanner::is_hidden ( )

Returns true if the file is hidden.

Returns
True if filename is hidden.
bool CL_DirectoryScanner::is_readable ( )

Returns true if the file is readable by the current user.

Returns
True if the file is readable.
bool CL_DirectoryScanner::is_writable ( )

Returns true if the file is writable by the current user.

Returns
True if the file is writable.
bool CL_DirectoryScanner::next ( )

Find next file in directory scan.

Returns
false if no more files was found.
bool CL_DirectoryScanner::scan ( const CL_String pathname)

Selects the directory to scan through.

Selects the directory to scan through

Parameters
pathnamePath to the directory to scan (without trailing slash)
Returns
true if the directory can be accessed.
bool CL_DirectoryScanner::scan ( const CL_String pathname,
const CL_String pattern 
)

Selects the directory to scan through.

Selects the directory to scan through and use a matching pattern on the files.

WIN32: The pattern is normal DOS pattern matching ("*.*", ?) Unix: The pattern is normal pattern matching (*, ?)

Parameters
pathnamePath to the directory to scan (without trailing slash)
patternPattern to match files against.
Returns
true if the directory can be accessed.

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