tue_filesystem
Public Member Functions | Private Attributes | List of all members
tue::filesystem::Crawler Class Reference

#include <crawler.h>

Public Member Functions

 Crawler ()
 
 Crawler (const Path &root_path)
 
bool nextPath (Path &path)
 
void setIgnoreHiddenDirectories (bool b=true)
 
void setIgnoreHiddenFiles (bool b=true)
 
void setListDirectories (bool b=true)
 
void setListFiles (bool b=true)
 
void setRecursive (bool b=true)
 
void setRootPath (const Path &root_path)
 
virtual ~Crawler ()
 

Private Attributes

bool ignore_hidden_dirs_
 If set, hidden directories are not expanded. More...
 
bool ignore_hidden_files_
 If set, hidden files are not returned in the iterator. More...
 
boost::filesystem::recursive_directory_iterator it_dir_
 
bool list_dirs_
 If set, iterator returns found directories. More...
 
bool list_files_
 If set, iterator returns found files. More...
 
bool recursive_
 If set, iterator also returns content of sub-directories. More...
 

Detailed Description

File system crawler, recursively walk over all files and directories in a tree from the provided root path.

Definition at line 18 of file crawler.h.

Constructor & Destructor Documentation

◆ Crawler() [1/2]

tue::filesystem::Crawler::Crawler ( )

Default constructor of the crawler iterator class. Creates an iterator that returns all non-hidden files in all non-hidden (sub-)directories.

Note
Root path must be set usng setRootPath before usage.

Definition at line 12 of file crawler.cpp.

◆ Crawler() [2/2]

tue::filesystem::Crawler::Crawler ( const Path root_path)

Constructor of the crawler iterator with a root path. Creates an iterator that returns all non-hidden files in all non-hidden (sub-)directories.

Parameters
root_pathStarting point of the sub-tree to expand.

Definition at line 17 of file crawler.cpp.

◆ ~Crawler()

tue::filesystem::Crawler::~Crawler ( )
virtual

Desctructor

Definition at line 23 of file crawler.cpp.

Member Function Documentation

◆ nextPath()

bool tue::filesystem::Crawler::nextPath ( Path path)

Get the next path at the file system of the crawl.

Parameters
path[out] Next found path at the file system, if the function returns successfully.
Returns
Whether a next path was found, otherwise the crawl is finished.

Definition at line 33 of file crawler.cpp.

◆ setIgnoreHiddenDirectories()

void tue::filesystem::Crawler::setIgnoreHiddenDirectories ( bool  b = true)
inline

Enable or disable iterating over hidden directories.

Parameters
bWhether to skip hidden directories.

Definition at line 58 of file crawler.h.

◆ setIgnoreHiddenFiles()

void tue::filesystem::Crawler::setIgnoreHiddenFiles ( bool  b = true)
inline

Enable or disable iterating over hidden files.

Parameters
bWhether to skip hidden files.

Definition at line 67 of file crawler.h.

◆ setListDirectories()

void tue::filesystem::Crawler::setListDirectories ( bool  b = true)
inline

Enable or disable returning directories in the iterator.

Parameters
bWhether directories should be returned in the iterator.

Definition at line 76 of file crawler.h.

◆ setListFiles()

void tue::filesystem::Crawler::setListFiles ( bool  b = true)
inline

Enable or disable returning files in the iterator.

Parameters
bWhether files should be returned in the iterator.

Definition at line 85 of file crawler.h.

◆ setRecursive()

void tue::filesystem::Crawler::setRecursive ( bool  b = true)
inline

Enable or disable iterating over sub-directories.

Parameters
bWhether to expand sub-directories too.

Definition at line 49 of file crawler.h.

◆ setRootPath()

void tue::filesystem::Crawler::setRootPath ( const Path root_path)

Sets (or change) the root path of the crawler instance. Also resets the iteration.

Parameters
root_pathNew root path to use for the iteration.

Definition at line 27 of file crawler.cpp.

Member Data Documentation

◆ ignore_hidden_dirs_

bool tue::filesystem::Crawler::ignore_hidden_dirs_
private

If set, hidden directories are not expanded.

Definition at line 99 of file crawler.h.

◆ ignore_hidden_files_

bool tue::filesystem::Crawler::ignore_hidden_files_
private

If set, hidden files are not returned in the iterator.

Definition at line 100 of file crawler.h.

◆ it_dir_

boost::filesystem::recursive_directory_iterator tue::filesystem::Crawler::it_dir_
private

Internal file system iterator.

Definition at line 105 of file crawler.h.

◆ list_dirs_

bool tue::filesystem::Crawler::list_dirs_
private

If set, iterator returns found directories.

Definition at line 101 of file crawler.h.

◆ list_files_

bool tue::filesystem::Crawler::list_files_
private

If set, iterator returns found files.

Definition at line 102 of file crawler.h.

◆ recursive_

bool tue::filesystem::Crawler::recursive_
private

If set, iterator also returns content of sub-directories.

Definition at line 98 of file crawler.h.


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