Periodically monitors file and invoke processing callback should the file change.
#include "common.h"
#include "watcher.h"
#include "atoms.h"
#include "cq.h"
#include "misc.h"
#include "walloc.h"
#include "override.h"
Data Structures | |
| struct | monitored |
| A monitored file. More... | |
Defines | |
| #define | MONITOR_PERIOD_MS (30*1000) /**< 30 seconds */ |
| 30 seconds | |
Functions | |
| RCSID ("$Id:watcher.c, v 1.4 2005/06/25 01:37:43 daichik Exp $") | |
| time_t | watcher_mtime (const gchar *filename) |
| Compute the modified time of the file on disk. | |
| void | watcher_check_mtime (gpointer unused_key, gpointer value, gpointer unused_udata) |
| Check each registered file for change -- hash table iterator callback. | |
| void | watcher_timer (cqueue_t *unused_cq, gpointer unused_udata) |
| Callout queue callback to perform periodic monitoring of the registered files. | |
| void | watcher_register (const gchar *filename, watcher_cb_t cb, gpointer udata) |
| Register new file to be monitored. | |
| void | watcher_register_path (const file_path_t *fp, watcher_cb_t cb, gpointer udata) |
| Same as watcher_register() but a path, i.e. | |
| void | watcher_free (struct monitored *m) |
| Free monitoring structure. | |
| void | watcher_unregister (const gchar *filename) |
| Cancel monitoring of specified file. | |
| void | watcher_unregister_path (const file_path_t *fp) |
| Same as watcher_unregister() but a path, i.e. | |
| void | watcher_init (void) |
| Initialization. | |
| void | free_monitored_kv (gpointer unused_key, gpointer value, gpointer unused_udata) |
| Free monitored structure -- hash table iterator callback. | |
| void | watcher_close (void) |
| Final cleanup. | |
Variables | |
| gpointer | monitor_ev = NULL |
| Monitoring event. | |
| GHashTable * | monitored = NULL |
| filename -> struct monitored | |
|
|
30 seconds
|
|
||||||||||||||||
|
Free monitored structure -- hash table iterator callback.
|
|
||||||||||||
|
|
|
||||||||||||||||
|
Check each registered file for change -- hash table iterator callback.
|
|
|
Final cleanup.
|
|
|
Free monitoring structure.
|
|
|
Initialization.
|
|
|
Compute the modified time of the file on disk.
|
|
||||||||||||||||
|
Register new file to be monitored. If the file was already monitored, cancel the previous monitoring action and replace it with this one.
|
|
||||||||||||||||
|
Same as watcher_register() but a path, i.e. a (dir, base) tuple is given instead of a complete filename. |
|
||||||||||||
|
Callout queue callback to perform periodic monitoring of the registered files.
|
|
|
Cancel monitoring of specified file.
|
|
|
Same as watcher_unregister() but a path, i.e. a (dir, base) tuple is given instead of a complete filename. |
|
|
Monitoring event.
|
|
|
filename -> struct monitored
|
1.3.6