Only allow including <gio/gio.h> from apps
[platform/upstream/glib.git] / gio / gfileattribute.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 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
24 #error "Only <gio/gio.h> can be included directly."
25 #endif
26
27 #ifndef __G_FILE_ATTRIBUTE_H__
28 #define __G_FILE_ATTRIBUTE_H__
29
30 #include <glib-object.h>
31
32 G_BEGIN_DECLS
33
34 /**
35  * GFileAttributeType:
36  * @G_FILE_ATTRIBUTE_TYPE_INVALID: indicates an invalid or uninitalized type.
37  * @G_FILE_ATTRIBUTE_TYPE_STRING: a null terminated UTF8 string.
38  * @G_FILE_ATTRIBUTE_TYPE_BYTE_STRING: a zero terminated string of non-zero bytes.
39  * @G_FILE_ATTRIBUTE_TYPE_BOOLEAN: a boolean value.
40  * @G_FILE_ATTRIBUTE_TYPE_UINT32: an unsigned 4-byte/32-bit integer.
41  * @G_FILE_ATTRIBUTE_TYPE_INT32: a signed 4-byte/32-bit integer.
42  * @G_FILE_ATTRIBUTE_TYPE_UINT64: an unsigned 8-byte/64-bit integer.
43  * @G_FILE_ATTRIBUTE_TYPE_INT64: a signed 8-byte/64-bit integer.
44  * @G_FILE_ATTRIBUTE_TYPE_OBJECT: a #GObject.
45  * 
46  * The data type for #GFileAttributeValue<!-- -->s. 
47  **/ 
48 typedef enum {
49   G_FILE_ATTRIBUTE_TYPE_INVALID = 0,
50   G_FILE_ATTRIBUTE_TYPE_STRING,
51   G_FILE_ATTRIBUTE_TYPE_BYTE_STRING, /* zero terminated string of non-zero bytes */
52   G_FILE_ATTRIBUTE_TYPE_BOOLEAN,
53   G_FILE_ATTRIBUTE_TYPE_UINT32,
54   G_FILE_ATTRIBUTE_TYPE_INT32,
55   G_FILE_ATTRIBUTE_TYPE_UINT64,
56   G_FILE_ATTRIBUTE_TYPE_INT64,
57   G_FILE_ATTRIBUTE_TYPE_OBJECT
58 } GFileAttributeType;
59
60 /**
61  * GFileAttributeFlags:
62  * @G_FILE_ATTRIBUTE_FLAGS_NONE: no flags set.
63  * @G_FILE_ATTRIBUTE_FLAGS_COPY_WITH_FILE: copy the attribute values when the file is copied.
64  * @G_FILE_ATTRIBUTE_FLAGS_COPY_WHEN_MOVED: copy the attribute values when the file is moved.
65  * 
66  * A flag specifying the behaviour of an attribute.
67  **/
68 typedef enum {
69   G_FILE_ATTRIBUTE_FLAGS_NONE = 0,
70   G_FILE_ATTRIBUTE_FLAGS_COPY_WITH_FILE = 1 << 0,
71   G_FILE_ATTRIBUTE_FLAGS_COPY_WHEN_MOVED = 1 << 1
72 } GFileAttributeFlags;
73
74 /**
75  * GFileAttributeStatus:
76  * @G_FILE_ATTRIBUTE_STATUS_UNSET: Attribute value is unset (empty).
77  * @G_FILE_ATTRIBUTE_STATUS_SET: Attribute value is set.
78  * @G_FILE_ATTRIBUTE_STATUS_ERROR_SETTING: Indicates an error in setting the value.
79  * 
80  * Used by g_file_set_attributes_from_info() when setting file attributes.
81  **/
82 typedef enum {
83   G_FILE_ATTRIBUTE_STATUS_UNSET = 0,
84   G_FILE_ATTRIBUTE_STATUS_SET,
85   G_FILE_ATTRIBUTE_STATUS_ERROR_SETTING
86 } GFileAttributeStatus;
87
88 #define G_FILE_ATTRIBUTE_VALUE_INIT {0}
89
90 /**
91  * GFileAttributeValue:
92  * @type: a #GFileAttributeType.
93  * @status: a #GFileAttributeStatus.
94  *
95  * Contains the value data for the Key-Value pair.
96  **/
97 typedef struct  {
98   GFileAttributeType type : 8;
99   GFileAttributeStatus status : 8;
100   union {
101     gboolean boolean;
102     gint32 int32;
103     guint32 uint32;
104     gint64 int64;
105     guint64 uint64;
106     char *string;
107     GQuark quark;
108     GObject *obj;
109   } u;
110 } GFileAttributeValue;
111
112 /**
113  * GFileAttributeInfo:
114  * @name: the name of the attribute.
115  * @type: the #GFileAttributeType type of the attribute.
116  * @flags: a set of #GFileAttributeFlags.
117  * 
118  * Information about a specific attribute. 
119  **/
120 typedef struct {
121   char *name;
122   GFileAttributeType type;
123   GFileAttributeFlags flags;
124 } GFileAttributeInfo;
125
126 /**
127  * GFileAttributeInfoList:
128  * @infos: an array of #GFileAttributeInfo<!-- -->s.
129  * @n_infos: the number of values in the array.
130  * 
131  * Acts as a lightweight registry for possible valid file attributes.
132  * The registry stores Key-Value pair formats as #GFileAttributeInfo<!-- -->s.
133  **/
134 typedef struct {
135   GFileAttributeInfo *infos;
136   int n_infos;
137 } GFileAttributeInfoList;
138
139 GFileAttributeValue *g_file_attribute_value_new             (void);
140 void                 g_file_attribute_value_free            (GFileAttributeValue *attr);
141 void                 g_file_attribute_value_clear           (GFileAttributeValue *attr);
142 void                 g_file_attribute_value_set             (GFileAttributeValue *attr,
143                                                              const GFileAttributeValue *new_value);
144 GFileAttributeValue *g_file_attribute_value_dup             (const GFileAttributeValue *other);
145
146 char *               g_file_attribute_value_as_string       (const GFileAttributeValue *attr);
147
148 const char *         g_file_attribute_value_get_string      (const GFileAttributeValue *attr);
149 const char *         g_file_attribute_value_get_byte_string (const GFileAttributeValue *attr);
150 gboolean             g_file_attribute_value_get_boolean     (const GFileAttributeValue *attr);
151 guint32              g_file_attribute_value_get_uint32      (const GFileAttributeValue *attr);
152 gint32               g_file_attribute_value_get_int32       (const GFileAttributeValue *attr);
153 guint64              g_file_attribute_value_get_uint64      (const GFileAttributeValue *attr);
154 gint64               g_file_attribute_value_get_int64       (const GFileAttributeValue *attr);
155 GObject *            g_file_attribute_value_get_object      (const GFileAttributeValue *attr);
156
157 void                 g_file_attribute_value_set_string      (GFileAttributeValue *attr,
158                                                              const char          *string);
159 void                 g_file_attribute_value_set_byte_string (GFileAttributeValue *attr,
160                                                              const char          *string);
161 void                 g_file_attribute_value_set_boolean     (GFileAttributeValue *attr,
162                                                              gboolean             value);
163 void                 g_file_attribute_value_set_uint32      (GFileAttributeValue *attr,
164                                                              guint32              value);
165 void                 g_file_attribute_value_set_int32       (GFileAttributeValue *attr,
166                                                              gint32               value);
167 void                 g_file_attribute_value_set_uint64      (GFileAttributeValue *attr,
168                                                              guint64              value);
169 void                 g_file_attribute_value_set_int64       (GFileAttributeValue *attr,
170                                                              gint64               value);
171 void                 g_file_attribute_value_set_object      (GFileAttributeValue *attr,
172                                                              GObject             *obj);
173
174 GFileAttributeInfoList *  g_file_attribute_info_list_new    (void);
175 GFileAttributeInfoList *  g_file_attribute_info_list_ref    (GFileAttributeInfoList *list);
176 void                      g_file_attribute_info_list_unref  (GFileAttributeInfoList *list);
177 GFileAttributeInfoList *  g_file_attribute_info_list_dup    (GFileAttributeInfoList *list);
178 const GFileAttributeInfo *g_file_attribute_info_list_lookup (GFileAttributeInfoList *list,
179                                                              const char             *name);
180 void                      g_file_attribute_info_list_add    (GFileAttributeInfoList *list,
181                                                              const char             *name,
182                                                              GFileAttributeType      type,
183                                                              GFileAttributeFlags     flags);
184
185 G_END_DECLS
186
187
188 #endif /* __G_FILE_INFO_H__ */