Sese Framework  3.0.0
A cross-platform framework
Loading...
Searching...
No Matches
sese::system::FileNotifier Class Referencefinal

File Change Monitor. More...

#include <FileNotifier.h>

Classes

class  Impl
 

Public Types

using Ptr = std::unique_ptr<FileNotifier>
 
using OnCreateCallback = std::function<void(std::string_view)>
 
using OnMoveCallback = std::function<void(std::string_view, std::string_view)>
 
using OnModifyCallback = std::function<void(std::string_view)>
 
using OnDeleteCallback = std::function<void(std::string_view)>
 

Public Member Functions

 ~FileNotifier () noexcept
 
void start () const noexcept
 Start a thread to start processing the change event.
 
void shutdown () const noexcept
 Shut down the monitor and block until the background thread exits.
 
void setOnCreate (OnCreateCallback &&callback) const noexcept
 
void setOnMove (OnMoveCallback &&callback) const noexcept
 
void setOnModify (OnModifyCallback &&callback) const noexcept
 
void setOnDelete (OnDeleteCallback &&callback) const noexcept
 

Static Public Member Functions

static Ptr create (const std::string &path) noexcept
 
static Result< Ptr, ErrorCodecreateEx (const std::string &path) noexcept
 

Private Member Functions

 FileNotifier ()=default
 

Private Attributes

std::unique_ptr< Implimpl
 

Detailed Description

File Change Monitor.

Bug
This implementation has an inconsistent event order in Darwin compared to Windows and Linux.

In Darwin, multiple events for the same file are triggered first, while in Windows and Linux, events are triggered in chronological order.

Member Typedef Documentation

◆ OnCreateCallback

using sese::system::FileNotifier::OnCreateCallback = std::function<void(std::string_view)>

◆ OnDeleteCallback

using sese::system::FileNotifier::OnDeleteCallback = std::function<void(std::string_view)>

◆ OnModifyCallback

using sese::system::FileNotifier::OnModifyCallback = std::function<void(std::string_view)>

◆ OnMoveCallback

using sese::system::FileNotifier::OnMoveCallback = std::function<void(std::string_view, std::string_view)>

◆ Ptr

Constructor & Destructor Documentation

◆ ~FileNotifier()

FileNotifier::~FileNotifier ( )
noexcept

◆ FileNotifier()

sese::system::FileNotifier::FileNotifier ( )
privatedefault

Member Function Documentation

◆ create()

FileNotifier::Ptr FileNotifier::create ( const std::string & path)
staticnoexcept

Create file monitor

Parameters
pathThe path to the directory
Return values
nullptrCreation failed

References MAKE_UNIQUE_PRIVATE.

◆ createEx()

static Result< Ptr, ErrorCode > sese::system::FileNotifier::createEx ( const std::string & path)
staticnoexcept

◆ setOnCreate()

void FileNotifier::setOnCreate ( OnCreateCallback && callback) const
noexcept

Set the callback function to be called when a file is created

Parameters
callbackCallback function

◆ setOnDelete()

void FileNotifier::setOnDelete ( OnDeleteCallback && callback) const
noexcept

Set the callback function to be called when a file is deleted

Parameters
callbackCallback function

◆ setOnModify()

void FileNotifier::setOnModify ( OnModifyCallback && callback) const
noexcept

Set the callback function to be called when a file is modified

Parameters
callbackCallback function

◆ setOnMove()

void FileNotifier::setOnMove ( OnMoveCallback && callback) const
noexcept

Set the callback function to be called when a file is moved

Parameters
callbackCallback function

◆ shutdown()

void FileNotifier::shutdown ( ) const
noexcept

Shut down the monitor and block until the background thread exits.

References impl.

◆ start()

void FileNotifier::start ( ) const
noexcept

Start a thread to start processing the change event.

References impl.

Member Data Documentation

◆ impl

std::unique_ptr<Impl> sese::system::FileNotifier::impl
private

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