Unravel Engine C++ Reference
Loading...
Searching...
No Matches
fs::watcher Class Reference

#include <watcher.h>

Classes

struct  entry
 
class  impl
 

Public Types

enum  entry_status {
  created , modified , removed , renamed ,
  unmodified
}
 
using notify_callback = std::function<void(const std::vector<entry>&, bool)>
 
using clock_t = std::chrono::steady_clock
 

Public Member Functions

 ~watcher ()
 
 watcher ()=default
 

Static Public Member Functions

static auto watch (const fs::path &path, const pattern_filter &filter, bool recursive, bool initial_list, clock_t::duration poll_interval, notify_callback callback) -> std::uint64_t
 Watches a file or directory for modification and call back the specified std::function. A list of modified files or directory is passed as argument of the callback. Use this version only if you are watching multiple files or a directory.
 
static auto watch (const fs::path &path, const std::string &filter_pattern, bool recursive, bool initial_list, clock_t::duration poll_interval, notify_callback callback) -> std::uint64_t
 
static void unwatch (std::uint64_t key)
 Un-watches a previously registered file or directory.
 
static void unwatch_all ()
 Un-watches all previously registered file or directory.
 
static void touch (const fs::path &path, bool recursive, fs::file_time_type time=fs::now())
 Sets the last modification time of a file or directory. by default sets the time to the current time.
 
static void pause ()
 
static void resume ()
 

Protected Member Functions

void close ()
 
void start ()
 

Static Protected Member Functions

static auto watch_impl (const fs::path &path, const pattern_filter &filter, bool recursive, bool initial_list, clock_t::duration poll_interval, notify_callback &list_callback) -> std::uint64_t
 
static void unwatch_impl (std::uint64_t key)
 
static void unwatch_all_impl ()
 

Protected Attributes

std::mutex mutex_
 Mutex for the file watchers.
 
std::atomic< bool > watching_ = {false}
 Atomic bool sync.
 
std::condition_variable cv_
 
std::thread thread_
 Thread that polls for changes.
 
std::map< std::uint64_t, std::shared_ptr< impl > > watchers_
 

Detailed Description

Definition at line 20 of file watcher.h.

Member Typedef Documentation

◆ clock_t

using fs::watcher::clock_t = std::chrono::steady_clock

Definition at line 43 of file watcher.h.

◆ notify_callback

using fs::watcher::notify_callback = std::function<void(const std::vector<entry>&, bool)>

Definition at line 42 of file watcher.h.

Member Enumeration Documentation

◆ entry_status

Enumerator
created 
modified 
removed 
renamed 
unmodified 

Definition at line 23 of file watcher.h.

Constructor & Destructor Documentation

◆ ~watcher()

fs::watcher::~watcher ( )

Definition at line 470 of file watcher.cpp.

◆ watcher()

fs::watcher::watcher ( )
default

Member Function Documentation

◆ close()

void fs::watcher::close ( )
protected

Definition at line 506 of file watcher.cpp.

◆ pause()

void fs::watcher::pause ( )
static

Definition at line 475 of file watcher.cpp.

◆ resume()

void fs::watcher::resume ( )
static

Definition at line 491 of file watcher.cpp.

◆ start()

void fs::watcher::start ( )
protected

Definition at line 519 of file watcher.cpp.

◆ touch()

void fs::watcher::touch ( const fs::path & path,
bool recursive,
fs::file_time_type time = fs::now() )
static

Sets the last modification time of a file or directory. by default sets the time to the current time.

Definition at line 436 of file watcher.cpp.

◆ unwatch()

void fs::watcher::unwatch ( std::uint64_t key)
static

Un-watches a previously registered file or directory.

Definition at line 426 of file watcher.cpp.

◆ unwatch_all()

void fs::watcher::unwatch_all ( )
static

Un-watches all previously registered file or directory.

Definition at line 431 of file watcher.cpp.

◆ unwatch_all_impl()

void fs::watcher::unwatch_all_impl ( )
staticprotected

Definition at line 607 of file watcher.cpp.

◆ unwatch_impl()

void fs::watcher::unwatch_impl ( std::uint64_t key)
staticprotected

Definition at line 596 of file watcher.cpp.

◆ watch() [1/2]

auto fs::watcher::watch ( const fs::path & path,
const pattern_filter & filter,
bool recursive,
bool initial_list,
clock_t::duration poll_interval,
notify_callback callback ) -> std::uint64_t
static

Watches a file or directory for modification and call back the specified std::function. A list of modified files or directory is passed as argument of the callback. Use this version only if you are watching multiple files or a directory.

Definition at line 416 of file watcher.cpp.

◆ watch() [2/2]

static auto fs::watcher::watch ( const fs::path & path,
const std::string & filter_pattern,
bool recursive,
bool initial_list,
clock_t::duration poll_interval,
notify_callback callback ) -> std::uint64_t
static

◆ watch_impl()

auto fs::watcher::watch_impl ( const fs::path & path,
const pattern_filter & filter,
bool recursive,
bool initial_list,
clock_t::duration poll_interval,
notify_callback & list_callback ) -> std::uint64_t
staticprotected

Definition at line 565 of file watcher.cpp.

Member Data Documentation

◆ cv_

std::condition_variable fs::watcher::cv_
protected

Definition at line 152 of file watcher.h.

◆ mutex_

std::mutex fs::watcher::mutex_
protected

Mutex for the file watchers.

Definition at line 148 of file watcher.h.

◆ thread_

std::thread fs::watcher::thread_
protected

Thread that polls for changes.

Definition at line 154 of file watcher.h.

◆ watchers_

std::map<std::uint64_t, std::shared_ptr<impl> > fs::watcher::watchers_
protected

Definition at line 157 of file watcher.h.

◆ watching_

std::atomic<bool> fs::watcher::watching_ = {false}
protected

Atomic bool sync.

Definition at line 150 of file watcher.h.


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