#include <FileWatcher.h>
Public Member Functions | |
| FileWatcher (const std::string &path, const std::function< void()> &callback) | |
| It initializes a new FileWatcher from a given path and callback function. More... | |
| void | unwatch () |
| Stops the thread watching the file. More... | |
| void | watch () |
| Starts a thread that will monitor the given file and call the previously given callback function. More... | |
| ~FileWatcher () | |
| Destructor. More... | |
Private Attributes | |
| std::function< void()> | m_callback |
| std::string | m_file |
| std::mutex | m_mutex |
| bool | m_running |
| std::thread | m_watcher |
Definition at line 46 of file FileWatcher.h.
| FileWatcher::FileWatcher | ( | const std::string & | path, |
| const std::function< void()> & | callback | ||
| ) |
It initializes a new FileWatcher from a given path and callback function.
| path | A UTF-8 String with a path to a file. |
| callback | A function with zero parameters and void return that will be called when the file is changed. |
Definition at line 38 of file FileWatcher.cpp.
| FileWatcher::~FileWatcher | ( | ) |
| void FileWatcher::unwatch | ( | ) |
Stops the thread watching the file.
Definition at line 91 of file FileWatcher.cpp.
References m_running.
| void FileWatcher::watch | ( | ) |
Starts a thread that will monitor the given file and call the previously given callback function.
Definition at line 49 of file FileWatcher.cpp.
References te::core::FileSystem::exists(), te::core::FileSystem::fileSize(), m_callback, m_file, m_mutex, m_running, and m_watcher.
|
private |
Definition at line 84 of file FileWatcher.h.
Referenced by watch().
|
private |
Definition at line 83 of file FileWatcher.h.
Referenced by watch().
|
private |
Definition at line 82 of file FileWatcher.h.
Referenced by watch().
|
private |
Definition at line 86 of file FileWatcher.h.
|
private |
Definition at line 85 of file FileWatcher.h.
Referenced by watch(), and ~FileWatcher().