Directory scanning class. More...
#include <directory_scanner.h>
Public Member Functions | |
| DirectoryScanner () | |
| Constructs directory scanner for iterating over a directory. | |
| ~DirectoryScanner () | |
| Destructor. | |
| std::string | get_directory_path () |
| Gets the directory being scanned. | |
| std::string | get_name () |
| Gets the name of the current file. | |
| std::string | get_pathname () |
| Gets the pathname of the current file. | |
| int | get_size () |
| Gets the size of the current file. | |
| bool | is_directory () |
| Returns true if the current file is a directory. | |
| bool | is_hidden () |
| Returns true if the file is hidden. | |
| bool | is_readable () |
| Returns true if the file is readable by the current user. | |
| bool | is_writable () |
| Returns true if the file is writable by the current user. | |
| bool | next () |
| Find next file in directory scan. | |
| bool | scan (const std::string &pathname) |
| Selects the directory to scan through. | |
| bool | scan (const std::string &pathname, const std::string &pattern) |
| Selects the directory to scan through. | |
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()) { cl_console_write_line(scanner.get_name()); } }
| clan::DirectoryScanner::DirectoryScanner | ( | ) |
Constructs directory scanner for iterating over a directory.
| clan::DirectoryScanner::~DirectoryScanner | ( | ) |
Destructor.
| std::string clan::DirectoryScanner::get_directory_path | ( | ) |
Gets the directory being scanned.
| std::string clan::DirectoryScanner::get_name | ( | ) |
Gets the name of the current file.
| std::string clan::DirectoryScanner::get_pathname | ( | ) |
Gets the pathname of the current file.
| int clan::DirectoryScanner::get_size | ( | ) |
Gets the size of the current file.
| bool clan::DirectoryScanner::is_directory | ( | ) |
Returns true if the current file is a directory.
| bool clan::DirectoryScanner::is_hidden | ( | ) |
Returns true if the file is hidden.
| bool clan::DirectoryScanner::is_readable | ( | ) |
Returns true if the file is readable by the current user.
| bool clan::DirectoryScanner::is_writable | ( | ) |
Returns true if the file is writable by the current user.
| bool clan::DirectoryScanner::next | ( | ) |
Find next file in directory scan.
| bool clan::DirectoryScanner::scan | ( | const std::string & | pathname | ) |
Selects the directory to scan through.
Selects the directory to scan through
| pathname | Path to the directory to scan (without trailing slash) |
| bool clan::DirectoryScanner::scan | ( | const std::string & | pathname, |
| const std::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 (*, ?)
| pathname | Path to the directory to scan (without trailing slash) |
| pattern | Pattern to match files against. |