Converted README to markdown
[rox-filer.git] / ROX-Filer / src / dir.h
blobdeb71aa67ecc1312c56de68e01e7d04da26bdc84
1 /*
2 * ROX-Filer, filer for the ROX desktop project
3 * Thomas Leonard, <tal197@users.sourceforge.net>
4 */
7 #ifndef _DIR_H
8 #define _DIR_H
10 #include <sys/types.h>
11 #include <dirent.h>
13 #include <signal.h>
14 #include <fcntl.h>
16 /* Check for [id]notify support */
17 #if defined(HAVE_SYS_INOTIFY_H)
18 # define USE_INOTIFY
19 #elif defined(DN_MULTISHOT) && defined(SIGRTMIN)
20 # define USE_DNOTIFY
21 #endif
22 #if defined(USE_INOTIFY) || defined(USE_DNOTIFY)
23 #define USE_NOTIFY
24 extern gboolean dnotify_wakeup_flag;
25 #endif
27 typedef enum {
28 DIR_START_SCAN, /* Set 'scanning' indicator */
29 DIR_END_SCAN, /* Clear 'scanning' indicator */
30 DIR_ADD, /* Add the listed items to the display */
31 DIR_REMOVE, /* Remove listed items from display */
32 DIR_UPDATE, /* Redraw these items */
33 DIR_ERROR_CHANGED, /* Check dir->error */
34 DIR_QUEUE_INTERESTING, /* Call dir_queue_recheck */
35 } DirAction;
37 typedef struct _DirUser DirUser;
38 typedef void (*DirCallback)(Directory *dir,
39 DirAction action,
40 GPtrArray *items,
41 gpointer data);
43 extern GFSCache *dir_cache;
45 struct _DirUser
47 DirCallback callback;
48 gpointer data;
51 typedef struct _DirectoryClass DirectoryClass;
53 struct _DirectoryClass {
54 GObjectClass parent;
57 struct _Directory
59 GObject object;
61 char *pathname; /* Internal use only */
62 GList *users; /* Functions to call on update */
63 char *error; /* NULL => no error */
65 struct stat stat_info; /* Internal use */
67 gboolean notify_active; /* Notify timeout is running */
68 gint idle_callback; /* Idle callback ID */
70 GHashTable *known_items; /* What our users know about */
71 GPtrArray *new_items; /* New items to add in */
72 GPtrArray *up_items; /* Items to redraw */
73 GPtrArray *gone_items; /* Items removed */
75 GList *recheck_list; /* Items to check on callback */
77 gboolean have_scanned; /* TRUE after first complete scan */
78 gboolean scanning; /* TRUE if we sent DIR_START_SCAN */
80 /* Indicates that the directory needs to be rescanned.
81 * This is cleared when scanning starts, and set when the fscache
82 * detects that the directory needs to be rescanned and is already
83 * scanning.
85 * If scanning finishes when this is set, or if someone attaches
86 * and scanning is not in progress, a rescan is triggered.
88 gboolean needs_update;
90 gint rescan_timeout; /* See dir_rescan_soon() */
92 #ifdef USE_NOTIFY
93 int notify_fd; /* -1 if not watching */
94 #endif
95 #ifdef USE_INOTIFY
96 guint inotify_source;
97 #endif
100 void dir_init(void);
101 void dir_attach(Directory *dir, DirCallback callback, gpointer data);
102 void dir_detach(Directory *dir, DirCallback callback, gpointer data);
103 void dir_update(Directory *dir, gchar *pathname);
104 void refresh_dirs(const char *path);
105 void dir_check_this(const guchar *path);
106 DirItem *dir_update_item(Directory *dir, const gchar *leafname);
107 void dir_merge_new(Directory *dir);
108 void dir_force_update_path(const gchar *path);
109 #if defined(USE_DNOTIFY)
110 void dnotify_wakeup(void);
111 #endif
112 void dir_drop_all_notifies(void);
113 void dir_queue_recheck(Directory *dir, DirItem *item);
115 #endif /* _DIR_H */