r214: Added support for mc's Virtual File System.
[rox-filer.git] / ROX-Filer / src / dir.h
blob81ec4a464f416bc88b5cdbc6b581cf04cb86c238
1 /*
2 * $Id$
4 * Thomas Leonard, <tal197@ecs.soton.ac.uk>
5 */
8 #ifndef _DIR_H
9 #define _DIR_H
11 #include <glib.h>
12 #include <sys/types.h>
13 #include <dirent.h>
15 typedef enum {
16 DIR_START_SCAN, /* Set 'scanning' indicator */
17 DIR_END_SCAN, /* Clear 'scanning' indicator */
18 DIR_ADD, /* Add the listed items to the display */
19 DIR_REMOVE, /* Remove listed items from display */
20 DIR_UPDATE, /* Redraw these items */
21 } DirAction;
23 typedef struct _Directory Directory;
24 typedef struct _DirItem DirItem;
25 typedef struct _DirUser DirUser;
26 typedef void (*DirCallback)(Directory *dir,
27 DirAction action,
28 GPtrArray *items,
29 gpointer data);
31 typedef enum
33 ITEM_FLAG_SYMLINK = 0x01, /* Is a symlink */
34 ITEM_FLAG_APPDIR = 0x02, /* Contains /AppInfo */
35 ITEM_FLAG_MOUNT_POINT = 0x04, /* Is in mtab or fstab */
36 ITEM_FLAG_MOUNTED = 0x08, /* Is in /etc/mtab */
37 ITEM_FLAG_TEMP_ICON = 0x10, /* Free icon after use */
38 ITEM_FLAG_EXEC_FILE = 0x20, /* File, and has an X bit set */
39 ITEM_FLAG_MAY_DELETE = 0x40, /* Delete on finishing scan */
40 } ItemFlags;
42 #include "fscache.h"
43 #include "pixmaps.h"
44 #include "type.h"
46 extern GFSCache *dir_cache;
48 struct _DirItem
50 char *leafname;
51 gboolean may_delete; /* Not yet found, this scan */
52 int base_type;
53 int flags;
54 mode_t mode;
55 off_t size;
56 time_t mtime;
57 MaskedPixmap *image;
58 MIME_type *mime_type;
59 int name_width;
60 int details_width;
61 uid_t uid;
62 gid_t gid;
65 struct _DirUser
67 DirCallback callback;
68 gpointer data;
71 struct _Directory
73 char *pathname; /* Internal use only */
74 int ref;
75 GList *users; /* Functions to call on update */
76 char *error; /* NULL => no error */
78 gboolean needs_update; /* When scan is finished, rescan */
79 gboolean notify_active; /* Notify timeout is running */
80 gboolean done_some_scanning; /* Read any items this scan? */
81 gint idle; /* Idle callback ID */
82 DIR *dir_handle; /* NULL => not scanning */
83 off_t dir_start; /* For seekdir() to beginning */
85 GPtrArray *items; /* What our users know about */
86 GPtrArray *new_items; /* New items to add in */
87 GPtrArray *up_items; /* Items to redraw */
90 void dir_init(void);
91 void dir_attach(Directory *dir, DirCallback callback, gpointer data);
92 void dir_detach(Directory *dir, DirCallback callback, gpointer data);
93 void dir_update(Directory *dir, gchar *pathname);
94 int dir_item_cmp(const void *a, const void *b);
95 void refresh_dirs(char *path);
97 #endif /* _DIR_H */