uicore::DirectoryScanner Class Referenceabstract

Directory scanning class. More...

#include <directory_scanner.h>

Public Member Functions

virtual std::string directory_path ()=0
 Gets the directory being scanned. More...
 
virtual bool is_directory ()=0
 Returns true if the current file is a directory. More...
 
virtual bool is_hidden ()=0
 Returns true if the file is hidden. More...
 
virtual bool is_readable ()=0
 Returns true if the file is readable by the current user. More...
 
virtual bool is_writable ()=0
 Returns true if the file is writable by the current user. More...
 
virtual std::string name ()=0
 Gets the name of the current file. More...
 
virtual bool next ()=0
 Find next file in directory scan. More...
 
virtual std::string pathname ()=0
 Gets the pathname of the current file. More...
 
virtual bool scan (const std::string &pathname)=0
 Selects the directory to scan through. More...
 
virtual bool scan (const std::string &pathname, const std::string &pattern)=0
 Selects the directory to scan through. More...
 
virtual int size ()=0
 Gets the size of the current file. More...
 

Static Public Member Functions

static std::shared_ptr< DirectoryScannercreate ()
 Constructs directory scanner for iterating over a directory. More...
 

Detailed Description

Directory scanning class.

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:

DirectoryScanner scanner; if (scanner.scan("/", "*")) { while (scanner.next()) { auto name = scanner.name(); } }

Member Function Documentation

static std::shared_ptr<DirectoryScanner> uicore::DirectoryScanner::create ( )
static

Constructs directory scanner for iterating over a directory.

virtual std::string uicore::DirectoryScanner::directory_path ( )
pure virtual

Gets the directory being scanned.

Returns
Directory being scanned. (including the trailing slash)
virtual bool uicore::DirectoryScanner::is_directory ( )
pure virtual

Returns true if the current file is a directory.

Returns
True if filename is a directory.
virtual bool uicore::DirectoryScanner::is_hidden ( )
pure virtual

Returns true if the file is hidden.

Returns
True if filename is hidden.
virtual bool uicore::DirectoryScanner::is_readable ( )
pure virtual

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

Returns
True if the file is readable.
virtual bool uicore::DirectoryScanner::is_writable ( )
pure virtual

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

Returns
True if the file is writable.
virtual std::string uicore::DirectoryScanner::name ( )
pure virtual

Gets the name of the current file.

Returns
The name of the current found file.
virtual bool uicore::DirectoryScanner::next ( )
pure virtual

Find next file in directory scan.

Returns
false if no more files was found.
virtual std::string uicore::DirectoryScanner::pathname ( )
pure virtual

Gets the pathname of the current file.

Returns
The name of the current found file, including the directory path.
virtual bool uicore::DirectoryScanner::scan ( const std::string pathname)
pure virtual

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.
virtual bool uicore::DirectoryScanner::scan ( const std::string pathname,
const std::string pattern 
)
pure virtual

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.
virtual int uicore::DirectoryScanner::size ( )
pure virtual

Gets the size of the current file.

Returns
The size of the current found file.

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