2006-05-21 16:11:05 -07:00
|
|
|
/*
|
2005-08-25 02:29:01 -07:00
|
|
|
* moofilewatch.h
|
|
|
|
*
|
2006-02-23 06:03:17 -08:00
|
|
|
* Copyright (C) 2004-2006 by Yevgen Muntyan <muntyan@math.tamu.edu>
|
2005-08-25 02:29:01 -07:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* See COPYING file that comes with this distribution.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Files and directory monitor. Uses FAM if present, or stat() otherwise.
|
|
|
|
On win32 does FindFirstChangeNotification and ReadDirectoryChangesW. */
|
|
|
|
|
2007-04-12 08:31:28 -07:00
|
|
|
#ifndef MOO_FILE_WATCH_H
|
|
|
|
#define MOO_FILE_WATCH_H
|
2005-08-25 02:29:01 -07:00
|
|
|
|
|
|
|
#include <glib-object.h>
|
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
|
|
|
|
2006-12-08 12:55:46 -08:00
|
|
|
#define MOO_TYPE_FILE_WATCH (moo_file_watch_get_type ())
|
|
|
|
#define MOO_TYPE_FILE_EVENT (moo_file_event_get_type ())
|
|
|
|
#define MOO_TYPE_FILE_EVENT_CODE (moo_file_event_code_get_type ())
|
2005-08-25 02:29:01 -07:00
|
|
|
|
|
|
|
typedef enum {
|
2006-12-08 12:55:46 -08:00
|
|
|
MOO_FILE_EVENT_CHANGED,
|
2006-12-15 19:12:31 -08:00
|
|
|
MOO_FILE_EVENT_CREATED,
|
2006-12-08 12:55:46 -08:00
|
|
|
MOO_FILE_EVENT_DELETED,
|
|
|
|
MOO_FILE_EVENT_ERROR
|
|
|
|
} MooFileEventCode;
|
|
|
|
|
|
|
|
struct _MooFileEvent {
|
|
|
|
MooFileEventCode code;
|
|
|
|
guint monitor_id;
|
|
|
|
char *filename;
|
|
|
|
GError *error;
|
2005-08-25 02:29:01 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _MooFileWatch MooFileWatch;
|
2006-12-08 12:55:46 -08:00
|
|
|
typedef struct _MooFileEvent MooFileEvent;
|
2005-08-25 02:29:01 -07:00
|
|
|
|
2006-12-08 12:55:46 -08:00
|
|
|
typedef void (*MooFileWatchCallback) (MooFileWatch *watch,
|
|
|
|
MooFileEvent *event,
|
|
|
|
gpointer user_data);
|
2005-08-25 02:29:01 -07:00
|
|
|
|
|
|
|
|
|
|
|
GType moo_file_watch_get_type (void) G_GNUC_CONST;
|
2006-12-08 12:55:46 -08:00
|
|
|
GType moo_file_event_get_type (void) G_GNUC_CONST;
|
|
|
|
GType moo_file_event_code_get_type (void) G_GNUC_CONST;
|
2005-08-25 02:29:01 -07:00
|
|
|
|
|
|
|
/* FAMOpen */
|
|
|
|
MooFileWatch *moo_file_watch_new (GError **error);
|
|
|
|
|
2006-12-08 12:55:46 -08:00
|
|
|
MooFileWatch *moo_file_watch_ref (MooFileWatch *watch);
|
|
|
|
void moo_file_watch_unref (MooFileWatch *watch);
|
|
|
|
|
2005-08-25 02:29:01 -07:00
|
|
|
/* FAMClose */
|
|
|
|
gboolean moo_file_watch_close (MooFileWatch *watch,
|
|
|
|
GError **error);
|
|
|
|
|
|
|
|
/* FAMMonitorDirectory, FAMMonitorFile */
|
2006-12-08 12:55:46 -08:00
|
|
|
guint moo_file_watch_create_monitor (MooFileWatch *watch,
|
2005-08-25 02:29:01 -07:00
|
|
|
const char *filename,
|
2006-12-08 12:55:46 -08:00
|
|
|
MooFileWatchCallback callback,
|
2005-08-25 02:29:01 -07:00
|
|
|
gpointer data,
|
2006-12-08 12:55:46 -08:00
|
|
|
GDestroyNotify notify,
|
2005-08-25 02:29:01 -07:00
|
|
|
GError **error);
|
2006-12-08 12:55:46 -08:00
|
|
|
/* FAMCancelMonitor */
|
|
|
|
void moo_file_watch_cancel_monitor (MooFileWatch *watch,
|
|
|
|
guint monitor_id);
|
2005-08-25 02:29:01 -07:00
|
|
|
|
|
|
|
|
|
|
|
G_END_DECLS
|
|
|
|
|
2007-04-12 08:31:28 -07:00
|
|
|
#endif /* MOO_FILE_WATCH_H */
|