1 /* GIO - GLib Input, Output and Streaming Library
3 * Copyright (C) 2006-2007 Red Hat, Inc.
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.
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.
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.
20 * Author: Alexander Larsson <alexl@redhat.com>
23 #ifndef __G_FILE_ATTRIBUTE_H__
24 #define __G_FILE_ATTRIBUTE_H__
26 #include <glib-object.h>
32 * @G_FILE_ATTRIBUTE_TYPE_INVALID: indicates an invalid or uninitalized type.
33 * @G_FILE_ATTRIBUTE_TYPE_STRING: a null terminated UTF8 string.
34 * @G_FILE_ATTRIBUTE_TYPE_BYTE_STRING: a zero terminated string of non-zero bytes.
35 * @G_FILE_ATTRIBUTE_TYPE_BOOLEAN: a boolean value.
36 * @G_FILE_ATTRIBUTE_TYPE_UINT32: an unsigned 4-byte/32-bit integer.
37 * @G_FILE_ATTRIBUTE_TYPE_INT32: a signed 4-byte/32-bit integer.
38 * @G_FILE_ATTRIBUTE_TYPE_UINT64: an unsigned 8-byte/64-bit integer.
39 * @G_FILE_ATTRIBUTE_TYPE_INT64: a signed 8-byte/64-bit integer.
40 * @G_FILE_ATTRIBUTE_TYPE_OBJECT: a #GObject.
42 * The data type for #GFileAttributeValue<!-- -->s.
45 G_FILE_ATTRIBUTE_TYPE_INVALID = 0,
46 G_FILE_ATTRIBUTE_TYPE_STRING,
47 G_FILE_ATTRIBUTE_TYPE_BYTE_STRING, /* zero terminated string of non-zero bytes */
48 G_FILE_ATTRIBUTE_TYPE_BOOLEAN,
49 G_FILE_ATTRIBUTE_TYPE_UINT32,
50 G_FILE_ATTRIBUTE_TYPE_INT32,
51 G_FILE_ATTRIBUTE_TYPE_UINT64,
52 G_FILE_ATTRIBUTE_TYPE_INT64,
53 G_FILE_ATTRIBUTE_TYPE_OBJECT
57 * GFileAttributeFlags:
58 * @G_FILE_ATTRIBUTE_FLAGS_NONE: no flags set.
59 * @G_FILE_ATTRIBUTE_FLAGS_COPY_WITH_FILE: copy the attribute values when the file is copied.
60 * @G_FILE_ATTRIBUTE_FLAGS_COPY_WHEN_MOVED: copy the attribute values when the file is moved.
62 * A flag specifying the behaviour of an attribute.
65 G_FILE_ATTRIBUTE_FLAGS_NONE = 0,
66 G_FILE_ATTRIBUTE_FLAGS_COPY_WITH_FILE = 1 << 0,
67 G_FILE_ATTRIBUTE_FLAGS_COPY_WHEN_MOVED = 1 << 1
68 } GFileAttributeFlags;
71 * GFileAttributeStatus:
72 * @G_FILE_ATTRIBUTE_STATUS_UNSET: Attribute value is unset (empty).
73 * @G_FILE_ATTRIBUTE_STATUS_SET: Attribute value is set.
74 * @G_FILE_ATTRIBUTE_STATUS_ERROR_SETTING: Indicates an error in setting the value.
76 * Used by g_file_set_attributes_from_info() when setting file attributes.
79 G_FILE_ATTRIBUTE_STATUS_UNSET = 0,
80 G_FILE_ATTRIBUTE_STATUS_SET,
81 G_FILE_ATTRIBUTE_STATUS_ERROR_SETTING
82 } GFileAttributeStatus;
84 #define G_FILE_ATTRIBUTE_VALUE_INIT {0}
87 * GFileAttributeValue:
88 * @type: a #GFileAttributeType.
89 * @status: a #GFileAttributeStatus.
91 * Contains the value data for the Key-Value pair.
94 GFileAttributeType type : 8;
95 GFileAttributeStatus status : 8;
106 } GFileAttributeValue;
109 * GFileAttributeInfo:
110 * @name: the name of the attribute.
111 * @type: the #GFileAttributeType type of the attribute.
112 * @flags: a set of #GFileAttributeFlags.
114 * Information about a specific attribute.
118 GFileAttributeType type;
119 GFileAttributeFlags flags;
120 } GFileAttributeInfo;
123 * GFileAttributeInfoList:
124 * @infos: an array of #GFileAttributeInfo<!-- -->s.
125 * @n_infos: the number of values in the array.
127 * Acts as a lightweight registry for possible valid file attributes.
128 * The registry stores Key-Value pair formats as #GFileAttributeInfo<!-- -->s.
131 GFileAttributeInfo *infos;
133 } GFileAttributeInfoList;
135 GFileAttributeValue *g_file_attribute_value_new (void);
136 void g_file_attribute_value_free (GFileAttributeValue *attr);
137 void g_file_attribute_value_clear (GFileAttributeValue *attr);
138 void g_file_attribute_value_set (GFileAttributeValue *attr,
139 const GFileAttributeValue *new_value);
140 GFileAttributeValue *g_file_attribute_value_dup (const GFileAttributeValue *other);
142 char * g_file_attribute_value_as_string (const GFileAttributeValue *attr);
144 const char * g_file_attribute_value_get_string (const GFileAttributeValue *attr);
145 const char * g_file_attribute_value_get_byte_string (const GFileAttributeValue *attr);
146 gboolean g_file_attribute_value_get_boolean (const GFileAttributeValue *attr);
147 guint32 g_file_attribute_value_get_uint32 (const GFileAttributeValue *attr);
148 gint32 g_file_attribute_value_get_int32 (const GFileAttributeValue *attr);
149 guint64 g_file_attribute_value_get_uint64 (const GFileAttributeValue *attr);
150 gint64 g_file_attribute_value_get_int64 (const GFileAttributeValue *attr);
151 GObject * g_file_attribute_value_get_object (const GFileAttributeValue *attr);
153 void g_file_attribute_value_set_string (GFileAttributeValue *attr,
155 void g_file_attribute_value_set_byte_string (GFileAttributeValue *attr,
157 void g_file_attribute_value_set_boolean (GFileAttributeValue *attr,
159 void g_file_attribute_value_set_uint32 (GFileAttributeValue *attr,
161 void g_file_attribute_value_set_int32 (GFileAttributeValue *attr,
163 void g_file_attribute_value_set_uint64 (GFileAttributeValue *attr,
165 void g_file_attribute_value_set_int64 (GFileAttributeValue *attr,
167 void g_file_attribute_value_set_object (GFileAttributeValue *attr,
170 GFileAttributeInfoList * g_file_attribute_info_list_new (void);
171 GFileAttributeInfoList * g_file_attribute_info_list_ref (GFileAttributeInfoList *list);
172 void g_file_attribute_info_list_unref (GFileAttributeInfoList *list);
173 GFileAttributeInfoList * g_file_attribute_info_list_dup (GFileAttributeInfoList *list);
174 const GFileAttributeInfo *g_file_attribute_info_list_lookup (GFileAttributeInfoList *list,
176 void g_file_attribute_info_list_add (GFileAttributeInfoList *list,
178 GFileAttributeType type,
179 GFileAttributeFlags flags);
184 #endif /* __G_FILE_INFO_H__ */