32 #include "../Exception.h" 39 const std::function<
void()> &callback)
40 : m_file(path), m_callback(callback)
56 uintmax_t fileSize = 0;
64 std::this_thread::sleep_for(std::chrono::milliseconds(1000));
67 if(tempExists != exists)
70 std::lock_guard<std::mutex> lock(
m_mutex);
79 if(fileSize != tempSize)
82 std::lock_guard<std::mutex> lock(
m_mutex);
static bool exists(const std::string &path)
Checks if a given path in UTF-8 exists.
~FileWatcher()
Destructor.
void watch()
Starts a thread that will monitor the given file and call the previously given callback function...
std::function< void()> m_callback
A class for handling system files and paths.
This class is designed to watch a file.
void unwatch()
Stops the thread watching the file.
static uintmax_t fileSize(const std::string &path)
Returns the file size of a FILE in UTF-8.
FileWatcher(const std::string &path, const std::function< void()> &callback)
It initializes a new FileWatcher from a given path and callback function.