125a46d4518d7d7975e5ce92c2740a97cd244c18
[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 #ifndef __G_FILE_ATTRIBUTE_H__
24 #define __G_FILE_ATTRIBUTE_H__
25
26 #include <glib-object.h>
27
28 G_BEGIN_DECLS
29
30 typedef enum {
31   G_FILE_ATTRIBUTE_TYPE_INVALID = 0,
32   G_FILE_ATTRIBUTE_TYPE_STRING,
33   G_FILE_ATTRIBUTE_TYPE_BYTE_STRING, /* zero terminated string of non-zero bytes */
34   G_FILE_ATTRIBUTE_TYPE_BOOLEAN,
35   G_FILE_ATTRIBUTE_TYPE_UINT32,
36   G_FILE_ATTRIBUTE_TYPE_INT32,
37   G_FILE_ATTRIBUTE_TYPE_UINT64,
38   G_FILE_ATTRIBUTE_TYPE_INT64,
39   G_FILE_ATTRIBUTE_TYPE_OBJECT
40 } GFileAttributeType;
41
42 typedef enum {
43   G_FILE_ATTRIBUTE_FLAGS_NONE = 0,
44   G_FILE_ATTRIBUTE_FLAGS_COPY_WITH_FILE = 1 << 0,
45   G_FILE_ATTRIBUTE_FLAGS_COPY_WHEN_MOVED = 1 << 1
46 } GFileAttributeFlags;
47
48 /* Used by g_file_set_attributes_from_info */
49 typedef enum {
50   G_FILE_ATTRIBUTE_STATUS_UNSET = 0,
51   G_FILE_ATTRIBUTE_STATUS_SET,
52   G_FILE_ATTRIBUTE_STATUS_ERROR_SETTING
53 } GFileAttributeStatus;
54
55 #define G_FILE_ATTRIBUTE_VALUE_INIT {0}
56
57 typedef struct  {
58   GFileAttributeType type : 8;
59   GFileAttributeStatus status : 8;
60   union {
61     gboolean boolean;
62     gint32 int32;
63     guint32 uint32;
64     gint64 int64;
65     guint64 uint64;
66     char *string;
67     GQuark quark;
68     GObject *obj;
69   } u;
70 } GFileAttributeValue;
71
72 typedef struct {
73   char *name;
74   GFileAttributeType type;
75   GFileAttributeFlags flags;
76 } GFileAttributeInfo;
77
78 typedef struct {
79   GFileAttributeInfo *infos;
80   int n_infos;
81 } GFileAttributeInfoList;
82
83 GFileAttributeValue *g_file_attribute_value_new             (void);
84 void                 g_file_attribute_value_free            (GFileAttributeValue *attr);
85 void                 g_file_attribute_value_clear           (GFileAttributeValue *attr);
86 void                 g_file_attribute_value_set             (GFileAttributeValue *attr,
87                                                              const GFileAttributeValue *new_value);
88 GFileAttributeValue *g_file_attribute_value_dup             (const GFileAttributeValue *other);
89
90 char *               g_file_attribute_value_as_string       (const GFileAttributeValue *attr);
91
92 const char *         g_file_attribute_value_get_string      (const GFileAttributeValue *attr);
93 const char *         g_file_attribute_value_get_byte_string (const GFileAttributeValue *attr);
94 gboolean             g_file_attribute_value_get_boolean     (const GFileAttributeValue *attr);
95 guint32              g_file_attribute_value_get_uint32      (const GFileAttributeValue *attr);
96 gint32               g_file_attribute_value_get_int32       (const GFileAttributeValue *attr);
97 guint64              g_file_attribute_value_get_uint64      (const GFileAttributeValue *attr);
98 gint64               g_file_attribute_value_get_int64       (const GFileAttributeValue *attr);
99 GObject *            g_file_attribute_value_get_object      (const GFileAttributeValue *attr);
100
101 void                 g_file_attribute_value_set_string      (GFileAttributeValue *attr,
102                                                              const char          *string);
103 void                 g_file_attribute_value_set_byte_string (GFileAttributeValue *attr,
104                                                              const char          *string);
105 void                 g_file_attribute_value_set_boolean     (GFileAttributeValue *attr,
106                                                              gboolean             value);
107 void                 g_file_attribute_value_set_uint32      (GFileAttributeValue *attr,
108                                                              guint32              value);
109 void                 g_file_attribute_value_set_int32       (GFileAttributeValue *attr,
110                                                              gint32               value);
111 void                 g_file_attribute_value_set_uint64      (GFileAttributeValue *attr,
112                                                              guint64              value);
113 void                 g_file_attribute_value_set_int64       (GFileAttributeValue *attr,
114                                                              gint64               value);
115 void                 g_file_attribute_value_set_object      (GFileAttributeValue *attr,
116                                                              GObject             *obj);
117
118 GFileAttributeInfoList *  g_file_attribute_info_list_new    (void);
119 GFileAttributeInfoList *  g_file_attribute_info_list_ref    (GFileAttributeInfoList *list);
120 void                      g_file_attribute_info_list_unref  (GFileAttributeInfoList *list);
121 GFileAttributeInfoList *  g_file_attribute_info_list_dup    (GFileAttributeInfoList *list);
122 const GFileAttributeInfo *g_file_attribute_info_list_lookup (GFileAttributeInfoList *list,
123                                                              const char             *name);
124 void                      g_file_attribute_info_list_add    (GFileAttributeInfoList *list,
125                                                              const char             *name,
126                                                              GFileAttributeType      type,
127                                                              GFileAttributeFlags     flags);
128
129 G_END_DECLS
130
131
132 #endif /* __G_FILE_INFO_H__ */