gio/ docs/reference/gio Merged gio-standalone into glib.
[platform/upstream/glib.git] / gio / gfileinfo.h
1 /* GIO - GLib Input, Output and Streaming Library
2  * 
3  * Copyright (C) 2006-2007 Red Hat, Inc.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General
16  * Public License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18  * Boston, MA 02111-1307, USA.
19  *
20  * Author: Alexander Larsson <alexl@redhat.com>
21  */
22
23 #ifndef __G_FILE_INFO_H__
24 #define __G_FILE_INFO_H__
25
26 #include <glib-object.h>
27 #include <gio/gfileattribute.h>
28 #include <gio/gicon.h>
29
30 G_BEGIN_DECLS
31
32 #define G_TYPE_FILE_INFO         (g_file_info_get_type ())
33 #define G_FILE_INFO(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_FILE_INFO, GFileInfo))
34 #define G_FILE_INFO_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_FILE_INFO, GFileInfoClass))
35 #define G_IS_FILE_INFO(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_FILE_INFO))
36 #define G_IS_FILE_INFO_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_FILE_INFO))
37 #define G_FILE_INFO_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_FILE_INFO, GFileInfoClass))
38
39 typedef struct _GFileInfo        GFileInfo;
40 typedef struct _GFileInfoClass   GFileInfoClass;
41 typedef struct _GFileAttributeMatcher GFileAttributeMatcher;
42
43 typedef enum {
44   G_FILE_TYPE_UNKNOWN = 0,
45   G_FILE_TYPE_REGULAR,
46   G_FILE_TYPE_DIRECTORY,
47   G_FILE_TYPE_SYMBOLIC_LINK,
48   G_FILE_TYPE_SPECIAL, /* socket, fifo, blockdev, chardev */
49   G_FILE_TYPE_SHORTCUT,
50   G_FILE_TYPE_MOUNTABLE
51 } GFileType;
52
53 /* Common Attributes:  */
54
55 #define G_FILE_ATTRIBUTE_STD_TYPE "std:type"                     /* uint32 (GFileType) */
56 #define G_FILE_ATTRIBUTE_STD_IS_HIDDEN "std:is_hidden"           /* boolean */
57 #define G_FILE_ATTRIBUTE_STD_IS_BACKUP "std:is_backup"           /* boolean */
58 #define G_FILE_ATTRIBUTE_STD_IS_SYMLINK "std:is_symlink"         /* boolean */
59 #define G_FILE_ATTRIBUTE_STD_IS_VIRTUAL "std:is_virtual"         /* boolean */
60 #define G_FILE_ATTRIBUTE_STD_NAME "std:name"                     /* byte string */
61 #define G_FILE_ATTRIBUTE_STD_DISPLAY_NAME "std:display_name"     /* string */
62 #define G_FILE_ATTRIBUTE_STD_EDIT_NAME "std:edit_name"           /* string */
63 #define G_FILE_ATTRIBUTE_STD_COPY_NAME "std:copy_name"           /* string */
64 #define G_FILE_ATTRIBUTE_STD_ICON "std:icon"                     /* object (GIcon) */
65 #define G_FILE_ATTRIBUTE_STD_CONTENT_TYPE "std:content_type"     /* string */
66 #define G_FILE_ATTRIBUTE_STD_FAST_CONTENT_TYPE "std:fast_content_type" /* string */
67 #define G_FILE_ATTRIBUTE_STD_SIZE "std:size"                     /* uint64 */
68 #define G_FILE_ATTRIBUTE_STD_SYMLINK_TARGET "std:symlink_target" /* byte string */
69 #define G_FILE_ATTRIBUTE_STD_TARGET_URI "std:target_uri"         /* string */
70 #define G_FILE_ATTRIBUTE_STD_SORT_ORDER "std:sort_order"         /* int32  */
71
72 /* Entity tags, used to avoid missing updates on save */
73
74 #define G_FILE_ATTRIBUTE_ETAG_VALUE "etag:value"                 /* string */
75
76 /* File identifier, for e.g. avoiding loops when doing recursive directory scanning */
77
78 #define G_FILE_ATTRIBUTE_ID_FILE "id:file"                     /* string */
79 #define G_FILE_ATTRIBUTE_ID_FS "id:fs"                         /* string */
80
81 /* Calculated Access Rights for current user */
82
83 #define G_FILE_ATTRIBUTE_ACCESS_CAN_READ "access:can_read"       /* boolean */
84 #define G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE "access:can_write"     /* boolean */
85 #define G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE "access:can_execute" /* boolean */
86 #define G_FILE_ATTRIBUTE_ACCESS_CAN_DELETE "access:can_delete"   /* boolean */
87 #define G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH "access:can_trash"     /* boolean */
88 #define G_FILE_ATTRIBUTE_ACCESS_CAN_RENAME "access:can_rename"   /* boolean */ 
89 /* TODO: Should we have special version for directories? can_enumerate, etc */
90
91 /* Mountable attributes */
92
93 #define G_FILE_ATTRIBUTE_MOUNTABLE_CAN_MOUNT "mountable:can_mount"     /* boolean */
94 #define G_FILE_ATTRIBUTE_MOUNTABLE_CAN_UNMOUNT "mountable:can_unmount" /* boolean */
95 #define G_FILE_ATTRIBUTE_MOUNTABLE_CAN_EJECT "mountable:can_eject"     /* boolean */
96 #define G_FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE "mountable:unix_device" /* uint32 */
97 #define G_FILE_ATTRIBUTE_MOUNTABLE_HAL_UDI "mountable:hal_udi"         /* string */
98
99 /* Time attributes */
100
101   /* The last time the file content or an attribute was modified */
102 #define G_FILE_ATTRIBUTE_TIME_MODIFIED "time:modified"           /* uint64 */
103 #define G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC "time:modified_usec" /* uint32 */
104   /* The last time the file was read */
105 #define G_FILE_ATTRIBUTE_TIME_ACCESS "time:access"               /* uint64 */
106 #define G_FILE_ATTRIBUTE_TIME_ACCESS_USEC "time:access_usec"     /* uint32 */
107   /* The last time a file attribute was changed (e.g. unix ctime) */
108 #define G_FILE_ATTRIBUTE_TIME_CHANGED "time:changed"             /* uint64 */
109 #define G_FILE_ATTRIBUTE_TIME_CHANGED_USEC "time:changed_usec"   /* uint32 */
110   /* When the file was originally created (e.g. ntfs ctime) */
111 #define G_FILE_ATTRIBUTE_TIME_CREATED "time:created"             /* uint64 */
112 #define G_FILE_ATTRIBUTE_TIME_CREATED_USEC "time:created_usec"   /* uint32 */
113
114 /* Unix specific attributes */
115
116 #define G_FILE_ATTRIBUTE_UNIX_DEVICE "unix:device"               /* uint32 */
117 #define G_FILE_ATTRIBUTE_UNIX_INODE "unix:inode"                 /* uint64 */
118 #define G_FILE_ATTRIBUTE_UNIX_MODE "unix:mode"                   /* uint32 */
119 #define G_FILE_ATTRIBUTE_UNIX_NLINK "unix:nlink"                 /* uint32 */
120 #define G_FILE_ATTRIBUTE_UNIX_UID "unix:uid"                     /* uint32 */
121 #define G_FILE_ATTRIBUTE_UNIX_GID "unix:gid"                     /* uint32 */
122 #define G_FILE_ATTRIBUTE_UNIX_RDEV "unix:rdev"                   /* uint32 */
123 #define G_FILE_ATTRIBUTE_UNIX_BLOCK_SIZE "unix:block_size"       /* uint32 */
124 #define G_FILE_ATTRIBUTE_UNIX_BLOCKS "unix:blocks"               /* uint64 */
125 #define G_FILE_ATTRIBUTE_UNIX_IS_MOUNTPOINT "unix:is_mountpoint" /* boolean */
126
127 /* DOS specific attributes */
128
129 #define G_FILE_ATTRIBUTE_DOS_IS_ARCHIVE "dos:is_archive"         /* boolean */
130 #define G_FILE_ATTRIBUTE_DOS_IS_SYSTEM "dos:is_system"           /* boolean */
131
132 /* Owner attributes */
133
134 #define G_FILE_ATTRIBUTE_OWNER_USER "owner:user"                 /* string */
135 #define G_FILE_ATTRIBUTE_OWNER_USER_REAL "owner:user_real"       /* string */
136 #define G_FILE_ATTRIBUTE_OWNER_GROUP "owner:group"               /* string */
137
138 /* Thumbnails */
139
140 #define G_FILE_ATTRIBUTE_THUMBNAIL_PATH "thumbnail:path"         /* bytestring */
141 #define G_FILE_ATTRIBUTE_THUMBNAILING_FAILED "thumbnail:failed"         /* bytestring */
142
143 /* File system info (for g_file_get_filesystem_info) */
144
145 #define G_FILE_ATTRIBUTE_FS_SIZE "fs:size"                       /* uint64 */
146 #define G_FILE_ATTRIBUTE_FS_FREE "fs:free"                       /* uint64 */
147 #define G_FILE_ATTRIBUTE_FS_TYPE "fs:type"                       /* string */
148 #define G_FILE_ATTRIBUTE_FS_READONLY "fs:readonly"               /* boolean */
149
150 #define G_FILE_ATTRIBUTE_GVFS_BACKEND "gvfs:backend"             /* string */
151
152 GType g_file_info_get_type (void) G_GNUC_CONST;
153
154 GFileInfo *        g_file_info_new                       (void);
155 GFileInfo *        g_file_info_dup                       (GFileInfo  *other);
156 void               g_file_info_copy_into                 (GFileInfo  *src_info,
157                                                           GFileInfo  *dest_info);
158 gboolean           g_file_info_has_attribute             (GFileInfo  *info,
159                                                           const char *attribute);
160 char **            g_file_info_list_attributes           (GFileInfo  *info,
161                                                           const char *name_space);
162 GFileAttributeType g_file_info_get_attribute_type        (GFileInfo  *info,
163                                                           const char *attribute);
164 void               g_file_info_remove_attribute          (GFileInfo  *info,
165                                                           const char *attribute);
166 GFileAttributeValue * g_file_info_get_attribute          (GFileInfo  *info,
167                                                           const char *attribute);
168 const char *       g_file_info_get_attribute_string      (GFileInfo  *info,
169                                                           const char *attribute);
170 const char *       g_file_info_get_attribute_byte_string (GFileInfo  *info,
171                                                           const char *attribute);
172 gboolean           g_file_info_get_attribute_boolean     (GFileInfo  *info,
173                                                           const char *attribute);
174 guint32            g_file_info_get_attribute_uint32      (GFileInfo  *info,
175                                                           const char *attribute);
176 gint32             g_file_info_get_attribute_int32       (GFileInfo  *info,
177                                                           const char *attribute);
178 guint64            g_file_info_get_attribute_uint64      (GFileInfo  *info,
179                                                           const char *attribute);
180 gint64             g_file_info_get_attribute_int64       (GFileInfo  *info,
181                                                           const char *attribute);
182 GObject *          g_file_info_get_attribute_object      (GFileInfo  *info,
183                                                           const char *attribute);
184
185 void               g_file_info_set_attribute             (GFileInfo  *info,
186                                                           const char *attribute,
187                                                           const GFileAttributeValue *attr_value);
188 void               g_file_info_set_attribute_string      (GFileInfo  *info,
189                                                           const char *attribute,
190                                                           const char *attr_value);
191 void               g_file_info_set_attribute_byte_string (GFileInfo  *info,
192                                                           const char *attribute,
193                                                           const char *attr_value);
194 void               g_file_info_set_attribute_boolean     (GFileInfo  *info,
195                                                           const char *attribute,
196                                                           gboolean    attr_value);
197 void               g_file_info_set_attribute_uint32      (GFileInfo  *info,
198                                                           const char *attribute,
199                                                           guint32     attr_value);
200 void               g_file_info_set_attribute_int32       (GFileInfo  *info,
201                                                           const char *attribute,
202                                                           gint32      attr_value);
203 void               g_file_info_set_attribute_uint64      (GFileInfo  *info,
204                                                           const char *attribute,
205                                                           guint64     attr_value);
206 void               g_file_info_set_attribute_int64       (GFileInfo  *info,
207                                                           const char *attribute,
208                                                           gint64      attr_value);
209 void               g_file_info_set_attribute_object      (GFileInfo  *info,
210                                                           const char *attribute,
211                                                           GObject    *attr_value);
212
213 void               g_file_info_clear_status              (GFileInfo  *info);
214
215 /* Helper getters: */
216 GFileType         g_file_info_get_file_type          (GFileInfo         *info);
217 gboolean          g_file_info_get_is_hidden          (GFileInfo         *info);
218 gboolean          g_file_info_get_is_backup          (GFileInfo         *info);
219 gboolean          g_file_info_get_is_symlink         (GFileInfo         *info);
220 const char *      g_file_info_get_name               (GFileInfo         *info);
221 const char *      g_file_info_get_display_name       (GFileInfo         *info);
222 const char *      g_file_info_get_edit_name          (GFileInfo         *info);
223 GIcon *           g_file_info_get_icon               (GFileInfo         *info);
224 const char *      g_file_info_get_content_type       (GFileInfo         *info);
225 goffset           g_file_info_get_size               (GFileInfo         *info);
226 void              g_file_info_get_modification_time  (GFileInfo         *info,
227                                                       GTimeVal          *result);
228 const char *      g_file_info_get_symlink_target     (GFileInfo         *info);
229 const char *      g_file_info_get_etag               (GFileInfo         *info);
230 gint32            g_file_info_get_sort_order         (GFileInfo         *info);
231
232 void              g_file_info_set_attribute_mask     (GFileInfo         *info,
233                                                       GFileAttributeMatcher *mask);
234 void              g_file_info_unset_attribute_mask   (GFileInfo         *info);
235
236 /* Helper setters: */
237 void              g_file_info_set_file_type          (GFileInfo         *info,
238                                                       GFileType          type);
239 void              g_file_info_set_is_hidden          (GFileInfo         *info,
240                                                       gboolean           is_hidden);
241 void              g_file_info_set_is_symlink         (GFileInfo         *info,
242                                                       gboolean           is_symlink);
243 void              g_file_info_set_name               (GFileInfo         *info,
244                                                       const char        *name);
245 void              g_file_info_set_display_name       (GFileInfo         *info,
246                                                       const char        *display_name);
247 void              g_file_info_set_edit_name          (GFileInfo         *info,
248                                                       const char        *edit_name);
249 void              g_file_info_set_icon               (GFileInfo         *info,
250                                                       GIcon             *icon);
251 void              g_file_info_set_content_type       (GFileInfo         *info,
252                                                       const char        *content_type);
253 void              g_file_info_set_size               (GFileInfo         *info,
254                                                       goffset            size);
255 void              g_file_info_set_modification_time  (GFileInfo         *info,
256                                                       GTimeVal          *mtime);
257 void              g_file_info_set_symlink_target     (GFileInfo         *info,
258                                                       const char        *symlink_target);
259 void              g_file_info_set_sort_order         (GFileInfo         *info,
260                                                       gint32             sort_order);
261
262 /* Helper functions for attributes: */
263 /* TODO: Move this to glib when merging */
264 char *g_format_file_size_for_display (goffset size);
265
266 GFileAttributeMatcher *g_file_attribute_matcher_new            (const char            *attributes);
267 GFileAttributeMatcher *g_file_attribute_matcher_ref            (GFileAttributeMatcher *matcher);
268 void                   g_file_attribute_matcher_unref          (GFileAttributeMatcher *matcher);
269 gboolean               g_file_attribute_matcher_matches        (GFileAttributeMatcher *matcher,
270                                                                 const char            *attribute);
271 gboolean               g_file_attribute_matcher_matches_only   (GFileAttributeMatcher *matcher,
272                                                                 const char            *attribute);
273 gboolean               g_file_attribute_matcher_enumerate_namespace (GFileAttributeMatcher *matcher,
274                                                                      const char            *ns);
275 const char *           g_file_attribute_matcher_enumerate_next (GFileAttributeMatcher *matcher);
276
277 G_END_DECLS
278
279
280 #endif /* __G_FILE_INFO_H__ */