wex v24.10.0
Public Member Functions | Static Public Member Functions | List of all members
wex::dir Class Reference

Offers find_files method. More...

#include <wex/common/dir.h>

Inheritance diagram for wex::dir:
Inheritance graph
[legend]

Public Member Functions

 dir (const path &path, const data::dir &data=data::dir(), wxEvtHandler *eh=nullptr)
 Constructor.
 
virtual ~dir ()=default
 Destructor.
 
virtual void find_files_end () const
 Override for action after find_files has ended.
 
virtual bool on_dir (const path &) const
 Do something with the dir.
 
virtual bool on_file (const path &) const
 Do something with the file.
 
const auto & data () const
 Returns the data.
 
int find_files ()
 Finds matching files.
 
bool find_files (const tool &tool)
 Finds matching files, and runs specified tool.
 
const auto & get_path () const
 Returns the path.
 
auto * handler ()
 Returns the event handler.
 

Static Public Member Functions

static auto & get_statistics ()
 Returns the statistics.
 
- Static Public Member Functions inherited from wex::interruptible
static bool start ()
 Starts the interruptible process.
 
static bool end ()
 Stops the interruptible process.
 
static bool is_running ()
 Returns true if process is running.
 

Detailed Description

Offers find_files method.

By overriding on_dir and on_file you can take care of what to do with the result.

Constructor & Destructor Documentation

◆ dir()

wex::dir::dir ( const path & path,
const data::dir & data = data::dir(),
wxEvtHandler * eh = nullptr )
explicit

Constructor.

Parameters
paththe path to start finding
datathe dir data
ehevent handler to use, this results in using a separate thread for find_files.

Member Function Documentation

◆ find_files() [1/2]

int wex::dir::find_files ( )

Finds matching files.

This results in recursive calls for on_dir and on_file. Runs as a separate thread if event handler is setup, otherwise runs synchronized. Returns 1 if thread is started, or number of matches for synchronized runs. You can set a limit on retrieving files by setting max_matches in data::dir.

◆ find_files() [2/2]

bool wex::dir::find_files ( const tool & tool)

Finds matching files, and runs specified tool.

Returns true if thread is started, the event handler must have been set.

◆ on_dir()

virtual bool wex::dir::on_dir ( const path & ) const
virtual

Do something with the dir.

Default supports find and replace, and adding items to handler.

◆ on_file()

virtual bool wex::dir::on_file ( const path & ) const
virtual

Do something with the file.

Default supports find and replace, and adding items to handler.