20 #ifndef AW_INOTIFY_HXX
37 SmartCharPtr watched_file;
38 FileChangedCallback wf_cb;
39 FileChangedCallback user_cb;
43 void file_modified_handler(
const char *file,
ChangeReason reason)
const {
51 awar_selfile->
touch();
65 void remove_inotification() {
66 if (watched_file.isSet()) {
68 watched_file.setNull();
72 void awar_modified_handler() {
76 bool need_change_watch =
78 ? (watched_file.isNull() || strcmp(&*watched_file, &*file) != 0)
79 : watched_file.isSet();
81 if (need_change_watch) {
82 remove_inotification();
93 static void file_modified_wrapper(
const char *file,
ChangeReason reason,
FileWatch *watch) { watch->file_modified_handler(file, reason); }
94 static void awar_modified_wrapper(
AW_root*,
FileWatch *watch) { watch->awar_modified_handler(); }
98 FileWatch(
const char *sel_file_awar,
const FileChangedCallback& file_changed_cb) :
99 awar_selfile(
AW_root::SINGLETON->awar(sel_file_awar)),
100 wf_cb(makeFileChangedCallback(file_modified_wrapper, this)),
101 user_cb(file_changed_cb)
103 awar_selfile->
add_callback(makeRootCallback(awar_modified_wrapper,
this));
107 awar_selfile->
remove_callback(makeRootCallback(awar_modified_wrapper,
this));
108 remove_inotification();
113 #error FileWatch.h included twice
114 #endif // FILEWATCH_H
AW_awar * add_callback(const RootCallback &cb)
const char * read_char_pntr() const
void AW_remove_inotification(const char *file, const FileChangedCallback &fccb)
void AW_add_inotification(const char *file, const FileChangedCallback &fccb)
char * read_string() const
AW_awar * remove_callback(const RootCallback &cb)
bool GB_is_regularfile(const char *path)
FileWatch(const char *sel_file_awar, const FileChangedCallback &file_changed_cb)
GB_ERROR write_string(const char *aw_string)