summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2007-12-14 15:56:56 +0000
committerAlexander Larsson <alexl@src.gnome.org>2007-12-14 15:56:56 +0000
commitf5063650794c987868830241a630993e624eabd9 (patch)
tree284ecd8560cd24aac08acf42316ae38ba38c6259
parent2ceae92eeb706d21b06a59418a6b3cbcc41f4faa (diff)
downloadglib-f5063650794c987868830241a630993e624eabd9.tar.gz
Move GFileAttributeValue to a private header, as its sort of ugly.
2007-12-14 Alexander Larsson <alexl@redhat.com> * Makefile.am: * gfileattribute.[ch]: * gfileattribute-priv.h: Move GFileAttributeValue to a private header, as its sort of ugly. * gfile.[ch]: Make set_attribute take a type + a pointer instead of a GFileAttributeValue. * gfileinfo.[ch]: Fix up for above changes. Add g_file_info_get_attribute_data to get all info in one call, g_file_info_get_attribute_status to get the status and g_file_info_get_attribute_as_string. * gio.symbols: * glocalfile.c: * glocalfileinfo.[ch]: Update for changes * gunixmounts.c: Make _guess_type static. svn path=/trunk/; revision=6129
-rw-r--r--gio/ChangeLog26
-rw-r--r--gio/Makefile.am1
-rw-r--r--gio/gfile.c63
-rw-r--r--gio/gfile.h6
-rw-r--r--gio/gfileattribute-priv.h89
-rw-r--r--gio/gfileattribute.c201
-rw-r--r--gio/gfileattribute.h59
-rw-r--r--gio/gfileinfo.c190
-rw-r--r--gio/gfileinfo.h12
-rw-r--r--gio/gio.symbols27
-rw-r--r--gio/glocalfile.c6
-rw-r--r--gio/glocalfileinfo.c44
-rw-r--r--gio/glocalfileinfo.h3
-rw-r--r--gio/gunixmounts.c10
14 files changed, 455 insertions, 282 deletions
diff --git a/gio/ChangeLog b/gio/ChangeLog
index 3e87eceb7..d3cba2eeb 100644
--- a/gio/ChangeLog
+++ b/gio/ChangeLog
@@ -1,3 +1,29 @@
+2007-12-14 Alexander Larsson <alexl@redhat.com>
+
+ * Makefile.am:
+ * gfileattribute.[ch]:
+ * gfileattribute-priv.h:
+ Move GFileAttributeValue to a private header, as
+ its sort of ugly.
+
+ * gfile.[ch]:
+ Make set_attribute take a type + a pointer instead
+ of a GFileAttributeValue.
+
+ * gfileinfo.[ch]:
+ Fix up for above changes.
+ Add g_file_info_get_attribute_data to get
+ all info in one call, g_file_info_get_attribute_status
+ to get the status and g_file_info_get_attribute_as_string.
+
+ * gio.symbols:
+ * glocalfile.c:
+ * glocalfileinfo.[ch]:
+ Update for changes
+
+ * gunixmounts.c:
+ Make _guess_type static.
+
2007-12-14 Yevgen Muntyan <muntyan@tamu.edu>
* Makefile.am:
diff --git a/gio/Makefile.am b/gio/Makefile.am
index e88ca33e5..4ab26d2c7 100644
--- a/gio/Makefile.am
+++ b/gio/Makefile.am
@@ -141,6 +141,7 @@ libgio_2_0_la_SOURCES = \
gdummyfile.c \
gfile.c \
gfileattribute.c \
+ gfileattribute-priv.h \
gfileenumerator.c \
gfileicon.c \
gfileinfo.c \
diff --git a/gio/gfile.c b/gio/gfile.c
index feeb8f7ac..b2a418389 100644
--- a/gio/gfile.c
+++ b/gio/gfile.c
@@ -31,6 +31,7 @@
#include "gioscheduler.h"
#include <glocalfile.h>
#include "gsimpleasyncresult.h"
+#include "gfileattribute-priv.h"
#include "gpollfilemonitor.h"
#include "glibintl.h"
@@ -2566,7 +2567,8 @@ g_file_query_writable_namespaces (GFile *file,
* g_file_set_attribute:
* @file: input #GFile.
* @attribute: a string containing the attribute's name.
- * @value: a set of #GFileAttributeValue.
+ * @type: The type of the attribute
+ * @value_p: a pointer to the value (or the pointer itself if the type is a pointer type)
* @flags: a set of #GFileQueryInfoFlags.
* @cancellable: optional #GCancellable object, %NULL to ignore.
* @error: a #GError, or %NULL
@@ -2582,7 +2584,8 @@ g_file_query_writable_namespaces (GFile *file,
gboolean
g_file_set_attribute (GFile *file,
const char *attribute,
- const GFileAttributeValue *value,
+ GFileAttributeType type,
+ gpointer value_p,
GFileQueryInfoFlags flags,
GCancellable *cancellable,
GError **error)
@@ -2605,7 +2608,7 @@ g_file_set_attribute (GFile *file,
return FALSE;
}
- return (* iface->set_attribute) (file, attribute, value, flags, cancellable, error);
+ return (* iface->set_attribute) (file, attribute, type, value_p, flags, cancellable, error);
}
/**
@@ -2676,12 +2679,14 @@ g_file_real_set_attributes_from_info (GFile *file,
for (i = 0; attributes[i] != NULL; i++)
{
- value = (GFileAttributeValue *)g_file_info_get_attribute (info, attributes[i]);
+ value = _g_file_info_get_attribute_value (info, attributes[i]);
if (value->status != G_FILE_ATTRIBUTE_STATUS_UNSET)
continue;
- if (!g_file_set_attribute (file, attributes[i], value, flags, cancellable, error))
+ if (!g_file_set_attribute (file, attributes[i],
+ value->type, _g_file_attribute_value_peek_as_pointer (value),
+ flags, cancellable, error))
{
value->status = G_FILE_ATTRIBUTE_STATUS_ERROR_SETTING;
res = FALSE;
@@ -2790,11 +2795,9 @@ g_file_set_attribute_string (GFile *file,
GCancellable *cancellable,
GError **error)
{
- GFileAttributeValue v;
-
- v.type = G_FILE_ATTRIBUTE_TYPE_STRING;
- v.u.string = (char *)value;
- return g_file_set_attribute (file, attribute, &v, flags, cancellable, error);
+ return g_file_set_attribute (file, attribute,
+ G_FILE_ATTRIBUTE_TYPE_STRING, (gpointer)value,
+ flags, cancellable, error);
}
/**
@@ -2825,11 +2828,9 @@ g_file_set_attribute_byte_string (GFile *file,
GCancellable *cancellable,
GError **error)
{
- GFileAttributeValue v;
-
- v.type = G_FILE_ATTRIBUTE_TYPE_BYTE_STRING;
- v.u.string = (char *)value;
- return g_file_set_attribute (file, attribute, &v, flags, cancellable, error);
+ return g_file_set_attribute (file, attribute,
+ G_FILE_ATTRIBUTE_TYPE_BYTE_STRING, (gpointer)value,
+ flags, cancellable, error);
}
/**
@@ -2859,11 +2860,9 @@ g_file_set_attribute_uint32 (GFile *file,
GCancellable *cancellable,
GError **error)
{
- GFileAttributeValue v;
-
- v.type = G_FILE_ATTRIBUTE_TYPE_UINT32;
- v.u.uint32 = value;
- return g_file_set_attribute (file, attribute, &v, flags, cancellable, error);
+ return g_file_set_attribute (file, attribute,
+ G_FILE_ATTRIBUTE_TYPE_UINT32, &value,
+ flags, cancellable, error);
}
/**
@@ -2893,11 +2892,9 @@ g_file_set_attribute_int32 (GFile *file,
GCancellable *cancellable,
GError **error)
{
- GFileAttributeValue v;
-
- v.type = G_FILE_ATTRIBUTE_TYPE_INT32;
- v.u.int32 = value;
- return g_file_set_attribute (file, attribute, &v, flags, cancellable, error);
+ return g_file_set_attribute (file, attribute,
+ G_FILE_ATTRIBUTE_TYPE_INT32, &value,
+ flags, cancellable, error);
}
/**
@@ -2927,11 +2924,9 @@ g_file_set_attribute_uint64 (GFile *file,
GCancellable *cancellable,
GError **error)
{
- GFileAttributeValue v;
-
- v.type = G_FILE_ATTRIBUTE_TYPE_UINT64;
- v.u.uint64 = value;
- return g_file_set_attribute (file, attribute, &v, flags, cancellable, error);
+ return g_file_set_attribute (file, attribute,
+ G_FILE_ATTRIBUTE_TYPE_UINT64, &value,
+ flags, cancellable, error);
}
/**
@@ -2960,11 +2955,9 @@ g_file_set_attribute_int64 (GFile *file,
GCancellable *cancellable,
GError **error)
{
- GFileAttributeValue v;
-
- v.type = G_FILE_ATTRIBUTE_TYPE_INT64;
- v.u.int64 = value;
- return g_file_set_attribute (file, attribute, &v, flags, cancellable, error);
+ return g_file_set_attribute (file, attribute,
+ G_FILE_ATTRIBUTE_TYPE_INT64, &value,
+ flags, cancellable, error);
}
/**
diff --git a/gio/gfile.h b/gio/gfile.h
index 361c04ea6..3b63bf2df 100644
--- a/gio/gfile.h
+++ b/gio/gfile.h
@@ -341,7 +341,8 @@ struct _GFileIface
gboolean (*set_attribute) (GFile *file,
const char *attribute,
- const GFileAttributeValue *value,
+ GFileAttributeType type,
+ gpointer value_p,
GFileQueryInfoFlags flags,
GCancellable *cancellable,
GError **error);
@@ -679,7 +680,8 @@ GFileAttributeInfoList *g_file_query_writable_namespaces (GFile
GError **error);
gboolean g_file_set_attribute (GFile *file,
const char *attribute,
- const GFileAttributeValue *value,
+ GFileAttributeType type,
+ gpointer value_p,
GFileQueryInfoFlags flags,
GCancellable *cancellable,
GError **error);
diff --git a/gio/gfileattribute-priv.h b/gio/gfileattribute-priv.h
new file mode 100644
index 000000000..99c3481b0
--- /dev/null
+++ b/gio/gfileattribute-priv.h
@@ -0,0 +1,89 @@
+/* GIO - GLib Input, Output and Streaming Library
+ *
+ * Copyright (C) 2006-2007 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Alexander Larsson <alexl@redhat.com>
+ */
+
+#ifndef __G_FILE_ATTRIBUTE_PRIV_H__
+#define __G_FILE_ATTRIBUTE_PRIV_H__
+
+#include "gfileattribute.h"
+#include "gfileinfo.h"
+
+#define G_FILE_ATTRIBUTE_VALUE_INIT {0}
+
+typedef struct {
+ GFileAttributeType type : 8;
+ GFileAttributeStatus status : 8;
+ union {
+ gboolean boolean;
+ gint32 int32;
+ guint32 uint32;
+ gint64 int64;
+ guint64 uint64;
+ char *string;
+ GObject *obj;
+ } u;
+} GFileAttributeValue;
+
+GFileAttributeValue *_g_file_attribute_value_new (void);
+void _g_file_attribute_value_free (GFileAttributeValue *attr);
+void _g_file_attribute_value_clear (GFileAttributeValue *attr);
+void _g_file_attribute_value_set (GFileAttributeValue *attr,
+ const GFileAttributeValue *new_value);
+GFileAttributeValue *_g_file_attribute_value_dup (const GFileAttributeValue *other);
+gpointer _g_file_attribute_value_peek_as_pointer (GFileAttributeValue *attr);
+
+char * _g_file_attribute_value_as_string (const GFileAttributeValue *attr);
+
+const char * _g_file_attribute_value_get_string (const GFileAttributeValue *attr);
+const char * _g_file_attribute_value_get_byte_string (const GFileAttributeValue *attr);
+gboolean _g_file_attribute_value_get_boolean (const GFileAttributeValue *attr);
+guint32 _g_file_attribute_value_get_uint32 (const GFileAttributeValue *attr);
+gint32 _g_file_attribute_value_get_int32 (const GFileAttributeValue *attr);
+guint64 _g_file_attribute_value_get_uint64 (const GFileAttributeValue *attr);
+gint64 _g_file_attribute_value_get_int64 (const GFileAttributeValue *attr);
+GObject * _g_file_attribute_value_get_object (const GFileAttributeValue *attr);
+
+void _g_file_attribute_value_set_from_pointer(GFileAttributeValue *attr,
+ GFileAttributeType type,
+ gpointer value_p,
+ gboolean dup);
+void _g_file_attribute_value_set_string (GFileAttributeValue *attr,
+ const char *string);
+void _g_file_attribute_value_set_byte_string (GFileAttributeValue *attr,
+ const char *string);
+void _g_file_attribute_value_set_boolean (GFileAttributeValue *attr,
+ gboolean value);
+void _g_file_attribute_value_set_uint32 (GFileAttributeValue *attr,
+ guint32 value);
+void _g_file_attribute_value_set_int32 (GFileAttributeValue *attr,
+ gint32 value);
+void _g_file_attribute_value_set_uint64 (GFileAttributeValue *attr,
+ guint64 value);
+void _g_file_attribute_value_set_int64 (GFileAttributeValue *attr,
+ gint64 value);
+void _g_file_attribute_value_set_object (GFileAttributeValue *attr,
+ GObject *obj);
+
+
+GFileAttributeValue *_g_file_info_get_attribute_value (GFileInfo *info,
+ const char *attribute);
+
+#endif /* __G_FILE_ATTRIBUTE_PRIV_H__ */
diff --git a/gio/gfileattribute.c b/gio/gfileattribute.c
index 43f593f26..fc04a55d1 100644
--- a/gio/gfileattribute.c
+++ b/gio/gfileattribute.c
@@ -25,6 +25,7 @@
#include <string.h>
#include "gfileattribute.h"
+#include "gfileattribute-priv.h"
#include <glib-object.h>
#include "glibintl.h"
@@ -184,24 +185,24 @@
*
**/
-/**
- * g_file_attribute_value_free:
+/*
+ * _g_file_attribute_value_free:
* @attr: a #GFileAttributeValue.
*
* Frees the memory used by @attr.
*
**/
void
-g_file_attribute_value_free (GFileAttributeValue *attr)
+_g_file_attribute_value_free (GFileAttributeValue *attr)
{
g_return_if_fail (attr != NULL);
- g_file_attribute_value_clear (attr);
+ _g_file_attribute_value_clear (attr);
g_free (attr);
}
-/**
- * g_file_attribute_value_clear:
+/*
+ * _g_file_attribute_value_clear:
* @attr: a #GFileAttributeValue.
*
* Clears the value of @attr and sets its type to
@@ -209,7 +210,7 @@ g_file_attribute_value_free (GFileAttributeValue *attr)
*
**/
void
-g_file_attribute_value_clear (GFileAttributeValue *attr)
+_g_file_attribute_value_clear (GFileAttributeValue *attr)
{
g_return_if_fail (attr != NULL);
@@ -224,7 +225,7 @@ g_file_attribute_value_clear (GFileAttributeValue *attr)
attr->type = G_FILE_ATTRIBUTE_TYPE_INVALID;
}
-/**
+/*
* g_file_attribute_value_set:
* @attr: a #GFileAttributeValue to set the value in.
* @new_value: a #GFileAttributeValue to get the value from.
@@ -232,13 +233,13 @@ g_file_attribute_value_clear (GFileAttributeValue *attr)
* Sets an attribute's value from another attribute.
**/
void
-g_file_attribute_value_set (GFileAttributeValue *attr,
- const GFileAttributeValue *new_value)
+_g_file_attribute_value_set (GFileAttributeValue *attr,
+ const GFileAttributeValue *new_value)
{
g_return_if_fail (attr != NULL);
g_return_if_fail (new_value != NULL);
- g_file_attribute_value_clear (attr);
+ _g_file_attribute_value_clear (attr);
*attr = *new_value;
if (attr->type == G_FILE_ATTRIBUTE_TYPE_STRING ||
@@ -250,15 +251,15 @@ g_file_attribute_value_set (GFileAttributeValue *attr,
g_object_ref (attr->u.obj);
}
-/**
- * g_file_attribute_value_new:
+/*
+ * _g_file_attribute_value_new:
*
* Creates a new file attribute.
*
* Returns: a #GFileAttributeValue.
**/
GFileAttributeValue *
-g_file_attribute_value_new (void)
+_g_file_attribute_value_new (void)
{
GFileAttributeValue *attr;
@@ -267,8 +268,21 @@ g_file_attribute_value_new (void)
return attr;
}
+gpointer
+_g_file_attribute_value_peek_as_pointer (GFileAttributeValue *attr)
+{
+ switch (attr->type) {
+ case G_FILE_ATTRIBUTE_TYPE_STRING:
+ case G_FILE_ATTRIBUTE_TYPE_BYTE_STRING:
+ return attr->u.string;
+ case G_FILE_ATTRIBUTE_TYPE_OBJECT:
+ return attr->u.obj;
+ default:
+ return (gpointer) &attr->u;
+ }
+}
-/**
+/*
* g_file_attribute_value_dup:
* @other: a #GFileAttributeValue to duplicate.
*
@@ -277,7 +291,7 @@ g_file_attribute_value_new (void)
* Returns: a duplicate of the @other.
**/
GFileAttributeValue *
-g_file_attribute_value_dup (const GFileAttributeValue *other)
+_g_file_attribute_value_dup (const GFileAttributeValue *other)
{
GFileAttributeValue *attr;
@@ -285,7 +299,7 @@ g_file_attribute_value_dup (const GFileAttributeValue *other)
attr = g_new (GFileAttributeValue, 1);
attr->type = G_FILE_ATTRIBUTE_TYPE_INVALID;
- g_file_attribute_value_set (attr, other);
+ _g_file_attribute_value_set (attr, other);
return attr;
}
@@ -338,7 +352,7 @@ escape_byte_string (const char *str)
}
}
-/**
+/*
* g_file_attribute_value_as_string:
* @attr: a #GFileAttributeValue.
*
@@ -349,7 +363,7 @@ escape_byte_string (const char *str)
* if @attr is of type %G_FILE_ATTRIBUTE_TYPE_INVALID.
**/
char *
-g_file_attribute_value_as_string (const GFileAttributeValue *attr)
+_g_file_attribute_value_as_string (const GFileAttributeValue *attr)
{
char *str;
@@ -392,7 +406,7 @@ g_file_attribute_value_as_string (const GFileAttributeValue *attr)
return str;
}
-/**
+/*
* g_file_attribute_value_get_string:
* @attr: a #GFileAttributeValue.
*
@@ -402,7 +416,7 @@ g_file_attribute_value_as_string (const GFileAttributeValue *attr)
* Returns: the string value contained within the attribute, or %NULL.
**/
const char *
-g_file_attribute_value_get_string (const GFileAttributeValue *attr)
+_g_file_attribute_value_get_string (const GFileAttributeValue *attr)
{
if (attr == NULL)
return NULL;
@@ -412,7 +426,7 @@ g_file_attribute_value_get_string (const GFileAttributeValue *attr)
return attr->u.string;
}
-/**
+/*
* g_file_attribute_value_get_byte_string:
* @attr: a #GFileAttributeValue.
*
@@ -422,7 +436,7 @@ g_file_attribute_value_get_string (const GFileAttributeValue *attr)
* Returns: the byte string contained within the attribute or %NULL.
**/
const char *
-g_file_attribute_value_get_byte_string (const GFileAttributeValue *attr)
+_g_file_attribute_value_get_byte_string (const GFileAttributeValue *attr)
{
if (attr == NULL)
return NULL;
@@ -432,7 +446,7 @@ g_file_attribute_value_get_byte_string (const GFileAttributeValue *attr)
return attr->u.string;
}
-/**
+/*
* g_file_attribute_value_get_boolean:
* @attr: a #GFileAttributeValue.
*
@@ -442,7 +456,7 @@ g_file_attribute_value_get_byte_string (const GFileAttributeValue *attr)
* Returns: the boolean value contained within the attribute, or %FALSE.
**/
gboolean
-g_file_attribute_value_get_boolean (const GFileAttributeValue *attr)
+_g_file_attribute_value_get_boolean (const GFileAttributeValue *attr)
{
if (attr == NULL)
return FALSE;
@@ -452,7 +466,7 @@ g_file_attribute_value_get_boolean (const GFileAttributeValue *attr)
return attr->u.boolean;
}
-/**
+/*
* g_file_attribute_value_get_uint32:
* @attr: a #GFileAttributeValue.
*
@@ -462,7 +476,7 @@ g_file_attribute_value_get_boolean (const GFileAttributeValue *attr)
* Returns: the unsigned 32-bit integer from the attribute, or %0.
**/
guint32
-g_file_attribute_value_get_uint32 (const GFileAttributeValue *attr)
+_g_file_attribute_value_get_uint32 (const GFileAttributeValue *attr)
{
if (attr == NULL)
return 0;
@@ -472,7 +486,7 @@ g_file_attribute_value_get_uint32 (const GFileAttributeValue *attr)
return attr->u.uint32;
}
-/**
+/*
* g_file_attribute_value_get_int32:
* @attr: a #GFileAttributeValue.
*
@@ -482,7 +496,7 @@ g_file_attribute_value_get_uint32 (const GFileAttributeValue *attr)
* Returns: the signed 32-bit integer from the attribute, or %0.
**/
gint32
-g_file_attribute_value_get_int32 (const GFileAttributeValue *attr)
+_g_file_attribute_value_get_int32 (const GFileAttributeValue *attr)
{
if (attr == NULL)
return 0;
@@ -492,7 +506,7 @@ g_file_attribute_value_get_int32 (const GFileAttributeValue *attr)
return attr->u.int32;
}
-/**
+/*
* g_file_attribute_value_get_uint64:
* @attr: a #GFileAttributeValue.
*
@@ -502,7 +516,7 @@ g_file_attribute_value_get_int32 (const GFileAttributeValue *attr)
* Returns: the unsigned 64-bit integer from the attribute, or %0.
**/
guint64
-g_file_attribute_value_get_uint64 (const GFileAttributeValue *attr)
+_g_file_attribute_value_get_uint64 (const GFileAttributeValue *attr)
{
if (attr == NULL)
return 0;
@@ -512,7 +526,7 @@ g_file_attribute_value_get_uint64 (const GFileAttributeValue *attr)
return attr->u.uint64;
}
-/**
+/*
* g_file_attribute_value_get_int64:
* @attr: a #GFileAttributeValue.
*
@@ -522,7 +536,7 @@ g_file_attribute_value_get_uint64 (const GFileAttributeValue *attr)
* Returns: the signed 64-bit integer from the attribute, or %0.
**/
gint64
-g_file_attribute_value_get_int64 (const GFileAttributeValue *attr)
+_g_file_attribute_value_get_int64 (const GFileAttributeValue *attr)
{
if (attr == NULL)
return 0;
@@ -532,7 +546,7 @@ g_file_attribute_value_get_int64 (const GFileAttributeValue *attr)
return attr->u.int64;
}
-/**
+/*
* g_file_attribute_value_get_object:
* @attr: a #GFileAttributeValue.
*
@@ -542,7 +556,7 @@ g_file_attribute_value_get_int64 (const GFileAttributeValue *attr)
* Returns: the GObject from the attribute, or %0.
**/
GObject *
-g_file_attribute_value_get_object (const GFileAttributeValue *attr)
+_g_file_attribute_value_get_object (const GFileAttributeValue *attr)
{
if (attr == NULL)
return NULL;
@@ -551,8 +565,59 @@ g_file_attribute_value_get_object (const GFileAttributeValue *attr)
return attr->u.obj;
}
+
+
+void
+_g_file_attribute_value_set_from_pointer (GFileAttributeValue *value,
+ GFileAttributeType type,
+ gpointer value_p,
+ gboolean dup)
+{
+ _g_file_attribute_value_clear (value);
+ value->type = type;
+ switch (type)
+ {
+ case G_FILE_ATTRIBUTE_TYPE_STRING:
+ case G_FILE_ATTRIBUTE_TYPE_BYTE_STRING:
+ if (dup)
+ value->u.string = g_strdup (value_p);
+ else
+ value->u.string = value_p;
+ break;
+
+ case G_FILE_ATTRIBUTE_TYPE_OBJECT:
+ if (dup)
+ value->u.obj = g_object_ref (value_p);
+ else
+ value->u.obj = value_p;
+ break;
+
+ case G_FILE_ATTRIBUTE_TYPE_BOOLEAN:
+ value->u.boolean = *(gboolean *)value_p;
+ break;
+
+ case G_FILE_ATTRIBUTE_TYPE_UINT32:
+ value->u.uint32 = *(guint32 *)value_p;
+ break;
+
+ case G_FILE_ATTRIBUTE_TYPE_INT32:
+ value->u.int32 = *(gint32 *)value_p;
+ break;
+
+ case G_FILE_ATTRIBUTE_TYPE_UINT64:
+ value->u.uint64 = *(guint64 *)value_p;
+ break;
+
+ case G_FILE_ATTRIBUTE_TYPE_INT64:
+ value->u.int64 = *(gint64 *)value_p;
+ break;
+ default:
+ g_warning ("Unknown type specified in g_file_info_set_attribute\n");
+ break;
+ }
+}
-/**
+/*
* g_file_attribute_value_set_string:
* @attr: a #GFileAttributeValue.
* @string: a string to set within the type.
@@ -561,18 +626,18 @@ g_file_attribute_value_get_object (const GFileAttributeValue *attr)
*
**/
void
-g_file_attribute_value_set_string (GFileAttributeValue *attr,
- const char *string)
+_g_file_attribute_value_set_string (GFileAttributeValue *attr,
+ const char *string)
{
g_return_if_fail (attr != NULL);
g_return_if_fail (string != NULL);
- g_file_attribute_value_clear (attr);
+ _g_file_attribute_value_clear (attr);
attr->type = G_FILE_ATTRIBUTE_TYPE_STRING;
attr->u.string = g_strdup (string);
}
-/**
+/*
* g_file_attribute_value_set_byte_string:
* @attr: a #GFileAttributeValue.
* @string: a byte string to set within the type.
@@ -581,18 +646,18 @@ g_file_attribute_value_set_string (GFileAttributeValue *attr,
*
**/
void
-g_file_attribute_value_set_byte_string (GFileAttributeValue *attr,
- const char *string)
+_g_file_attribute_value_set_byte_string (GFileAttributeValue *attr,
+ const char *string)
{
g_return_if_fail (attr != NULL);
g_return_if_fail (string != NULL);
- g_file_attribute_value_clear (attr);
+ _g_file_attribute_value_clear (attr);
attr->type = G_FILE_ATTRIBUTE_TYPE_BYTE_STRING;
attr->u.string = g_strdup (string);
}
-/**
+/*
* g_file_attribute_value_set_boolean:
* @attr: a #GFileAttributeValue.
* @value: a #gboolean to set within the type.
@@ -601,17 +666,17 @@ g_file_attribute_value_set_byte_string (GFileAttributeValue *attr,
*
**/
void
-g_file_attribute_value_set_boolean (GFileAttributeValue *attr,
- gboolean value)
+_g_file_attribute_value_set_boolean (GFileAttributeValue *attr,
+ gboolean value)
{
g_return_if_fail (attr != NULL);
- g_file_attribute_value_clear (attr);
+ _g_file_attribute_value_clear (attr);
attr->type = G_FILE_ATTRIBUTE_TYPE_BOOLEAN;
attr->u.boolean = !!value;
}
-/**
+/*
* g_file_attribute_value_set_uint32:
* @attr: a #GFileAttributeValue.
* @value: a #guint32 to set within the type.
@@ -620,17 +685,17 @@ g_file_attribute_value_set_boolean (GFileAttributeValue *attr,
*
**/
void
-g_file_attribute_value_set_uint32 (GFileAttributeValue *attr,
- guint32 value)
+_g_file_attribute_value_set_uint32 (GFileAttributeValue *attr,
+ guint32 value)
{
g_return_if_fail (attr != NULL);
-
- g_file_attribute_value_clear (attr);
+
+ _g_file_attribute_value_clear (attr);
attr->type = G_FILE_ATTRIBUTE_TYPE_UINT32;
attr->u.uint32 = value;
}
-/**
+/*
* g_file_attribute_value_set_int32:
* @attr: a #GFileAttributeValue.
* @value: a #gint32 to set within the type.
@@ -639,17 +704,17 @@ g_file_attribute_value_set_uint32 (GFileAttributeValue *attr,
*
**/
void
-g_file_attribute_value_set_int32 (GFileAttributeValue *attr,
- gint32 value)
+_g_file_attribute_value_set_int32 (GFileAttributeValue *attr,
+ gint32 value)
{
g_return_if_fail (attr != NULL);
- g_file_attribute_value_clear (attr);
+ _g_file_attribute_value_clear (attr);
attr->type = G_FILE_ATTRIBUTE_TYPE_INT32;
attr->u.int32 = value;
}
-/**
+/*
* g_file_attribute_value_set_uint64:
* @attr: a #GFileAttributeValue.
* @value: a #guint64 to set within the type.
@@ -658,17 +723,17 @@ g_file_attribute_value_set_int32 (GFileAttributeValue *attr,
*
**/
void
-g_file_attribute_value_set_uint64 (GFileAttributeValue *attr,
- guint64 value)
+_g_file_attribute_value_set_uint64 (GFileAttributeValue *attr,
+ guint64 value)
{
g_return_if_fail (attr != NULL);
- g_file_attribute_value_clear (attr);
+ _g_file_attribute_value_clear (attr);
attr->type = G_FILE_ATTRIBUTE_TYPE_UINT64;
attr->u.uint64 = value;
}
-/**
+/*
* g_file_attribute_value_set_int64:
* @attr: a #GFileAttributeValue.
* @value: a #gint64 to set within the type.
@@ -677,17 +742,17 @@ g_file_attribute_value_set_uint64 (GFileAttributeValue *attr,
*
**/
void
-g_file_attribute_value_set_int64 (GFileAttributeValue *attr,
- gint64 value)
+_g_file_attribute_value_set_int64 (GFileAttributeValue *attr,
+ gint64 value)
{
g_return_if_fail (attr != NULL);
- g_file_attribute_value_clear (attr);
+ _g_file_attribute_value_clear (attr);
attr->type = G_FILE_ATTRIBUTE_TYPE_INT64;
attr->u.int64 = value;
}
-/**
+/*
* g_file_attribute_value_set_object:
* @attr: a #GFileAttributeValue.
* @obj: a #GObject.
@@ -697,13 +762,13 @@ g_file_attribute_value_set_int64 (GFileAttributeValue *attr,
*
**/
void
-g_file_attribute_value_set_object (GFileAttributeValue *attr,
- GObject *obj)
+_g_file_attribute_value_set_object (GFileAttributeValue *attr,
+ GObject *obj)
{
g_return_if_fail (attr != NULL);
g_return_if_fail (obj != NULL);
- g_file_attribute_value_clear (attr);
+ _g_file_attribute_value_clear (attr);
attr->type = G_FILE_ATTRIBUTE_TYPE_OBJECT;
attr->u.obj = g_object_ref (obj);
}
diff --git a/gio/gfileattribute.h b/gio/gfileattribute.h
index 10b608721..d5ef0d5c2 100644
--- a/gio/gfileattribute.h
+++ b/gio/gfileattribute.h
@@ -85,30 +85,6 @@ typedef enum {
G_FILE_ATTRIBUTE_STATUS_ERROR_SETTING
} GFileAttributeStatus;
-#define G_FILE_ATTRIBUTE_VALUE_INIT {0}
-
-/**
- * GFileAttributeValue:
- * @type: a #GFileAttributeType.
- * @status: a #GFileAttributeStatus.
- *
- * Contains the value data for the Key-Value pair.
- **/
-typedef struct {
- GFileAttributeType type : 8;
- GFileAttributeStatus status : 8;
- union {
- gboolean boolean;
- gint32 int32;
- guint32 uint32;
- gint64 int64;
- guint64 uint64;
- char *string;
- GQuark quark;
- GObject *obj;
- } u;
-} GFileAttributeValue;
-
/**
* GFileAttributeInfo:
* @name: the name of the attribute.
@@ -136,41 +112,6 @@ typedef struct {
int n_infos;
} GFileAttributeInfoList;
-GFileAttributeValue *g_file_attribute_value_new (void);
-void g_file_attribute_value_free (GFileAttributeValue *attr);
-void g_file_attribute_value_clear (GFileAttributeValue *attr);
-void g_file_attribute_value_set (GFileAttributeValue *attr,
- const GFileAttributeValue *new_value);
-GFileAttributeValue *g_file_attribute_value_dup (const GFileAttributeValue *other);
-
-char * g_file_attribute_value_as_string (const GFileAttributeValue *attr);
-
-const char * g_file_attribute_value_get_string (const GFileAttributeValue *attr);
-const char * g_file_attribute_value_get_byte_string (const GFileAttributeValue *attr);
-gboolean g_file_attribute_value_get_boolean (const GFileAttributeValue *attr);
-guint32 g_file_attribute_value_get_uint32 (const GFileAttributeValue *attr);
-gint32 g_file_attribute_value_get_int32 (const GFileAttributeValue *attr);
-guint64 g_file_attribute_value_get_uint64 (const GFileAttributeValue *attr);
-gint64 g_file_attribute_value_get_int64 (const GFileAttributeValue *attr);
-GObject * g_file_attribute_value_get_object (const GFileAttributeValue *attr);
-
-void g_file_attribute_value_set_string (GFileAttributeValue *attr,
- const char *string);
-void g_file_attribute_value_set_byte_string (GFileAttributeValue *attr,
- const char *string);
-void g_file_attribute_value_set_boolean (GFileAttributeValue *attr,
- gboolean value);
-void g_file_attribute_value_set_uint32 (GFileAttributeValue *attr,
- guint32 value);
-void g_file_attribute_value_set_int32 (GFileAttributeValue *attr,
- gint32 value);
-void g_file_attribute_value_set_uint64 (GFileAttributeValue *attr,
- guint64 value);
-void g_file_attribute_value_set_int64 (GFileAttributeValue *attr,
- gint64 value);
-void g_file_attribute_value_set_object (GFileAttributeValue *attr,
- GObject *obj);
-
GFileAttributeInfoList * g_file_attribute_info_list_new (void);
GFileAttributeInfoList * g_file_attribute_info_list_ref (GFileAttributeInfoList *list);
void g_file_attribute_info_list_unref (GFileAttributeInfoList *list);
diff --git a/gio/gfileinfo.c b/gio/gfileinfo.c
index 385e0bdb5..0f2ea3c92 100644
--- a/gio/gfileinfo.c
+++ b/gio/gfileinfo.c
@@ -40,6 +40,7 @@
#include <string.h>
#include "gfileinfo.h"
+#include "gfileattribute-priv.h"
#include "glibintl.h"
#include "gioalias.h"
@@ -65,6 +66,7 @@ struct _GFileInfoClass
GObjectClass parent_class;
};
+
static gboolean g_file_attribute_matcher_matches_id (GFileAttributeMatcher *matcher,
guint32 id);
@@ -210,7 +212,7 @@ g_file_info_finalize (GObject *object)
attrs = (GFileAttribute *)info->attributes->data;
for (i = 0; i < info->attributes->len; i++)
- g_file_attribute_value_clear (&attrs[i].value);
+ _g_file_attribute_value_clear (&attrs[i].value);
g_array_free (info->attributes, TRUE);
if (info->mask != NO_ATTRIBUTE_MASK)
@@ -268,7 +270,7 @@ g_file_info_copy_into (GFileInfo *src_info,
dest = (GFileAttribute *)dest_info->attributes->data;
for (i = 0; i < dest_info->attributes->len; i++)
- g_file_attribute_value_clear (&dest[i].value);
+ _g_file_attribute_value_clear (&dest[i].value);
g_array_set_size (dest_info->attributes,
src_info->attributes->len);
@@ -280,7 +282,7 @@ g_file_info_copy_into (GFileInfo *src_info,
{
dest[i].attribute = source[i].attribute;
dest[i].value.type = G_FILE_ATTRIBUTE_TYPE_INVALID;
- g_file_attribute_value_set (&dest[i].value, &source[i].value);
+ _g_file_attribute_value_set (&dest[i].value, &source[i].value);
}
if (src_info->mask == NO_ATTRIBUTE_MASK)
@@ -339,7 +341,7 @@ g_file_info_set_attribute_mask (GFileInfo *info,
if (!g_file_attribute_matcher_matches_id (mask,
attr->attribute))
{
- g_file_attribute_value_clear (&attr->value);
+ _g_file_attribute_value_clear (&attr->value);
g_array_remove_index (info->attributes, i);
i--;
}
@@ -553,24 +555,56 @@ g_file_info_remove_attribute (GFileInfo *info,
if (i < info->attributes->len &&
attrs[i].attribute == attr_id)
{
- g_file_attribute_value_clear (&attrs[i].value);
+ _g_file_attribute_value_clear (&attrs[i].value);
g_array_remove_index (info->attributes, i);
}
}
-/**
- * g_file_info_get_attribute:
- * @info: a #GFileInfo.
- * @attribute: a file attribute key.
- *
- * Gets an attribute value from a file info structure.
- *
- * Returns: a #GFileAttributeValue for the given @attribute, or
- * %NULL otherwise.
- **/
+gboolean
+g_file_info_get_attribute_data (GFileInfo *info,
+ const char *attribute,
+ GFileAttributeType *type,
+ gpointer *value_pp,
+ GFileAttributeStatus *status)
+{
+ GFileAttributeValue *value;
+
+ value = g_file_info_find_value_by_name (info, attribute);
+ if (value == NULL)
+ return FALSE;
+
+ if (status)
+ *status = value->status;
+
+ if (type)
+ *type = value->type;
+
+ if (value_pp)
+ *value_pp = _g_file_attribute_value_peek_as_pointer (value);
+
+ return TRUE;
+}
+
+GFileAttributeStatus
+g_file_info_get_attribute_status (GFileInfo *info,
+ const char *attribute)
+{
+ GFileAttributeValue *val;
+
+ g_return_val_if_fail (G_IS_FILE_INFO (info), 0);
+ g_return_val_if_fail (attribute != NULL && *attribute != '\0', 0);
+
+ val = g_file_info_find_value_by_name (info, attribute);
+ if (val)
+ return val->status;
+
+ return 0;
+}
+
+
GFileAttributeValue *
-g_file_info_get_attribute (GFileInfo *info,
- const char *attribute)
+_g_file_info_get_attribute_value (GFileInfo *info,
+ const char *attribute)
{
g_return_val_if_fail (G_IS_FILE_INFO (info), NULL);
@@ -580,6 +614,30 @@ g_file_info_get_attribute (GFileInfo *info,
}
/**
+ * g_file_info_get_attribute_as_string:
+ * @info: a #GFileInfo.
+ * @attribute: a file attribute key.
+ *
+ * Gets the value of a attribute, formated as a string.
+ * This escapes things as needed to make the string valid
+ * utf8.
+ *
+ * Returns: a utf8 string associated with the given @attribute.
+ * When you're done with the string it must be freed.
+ **/
+char *
+g_file_info_get_attribute_as_string (GFileInfo *info,
+ const char *attribute)
+{
+ GFileAttributeValue *val;
+ val = _g_file_info_get_attribute_value (info, attribute);
+ if (val)
+ return _g_file_attribute_value_as_string (val);
+ return NULL;
+}
+
+
+/**
* g_file_info_get_attribute_object:
* @info: a #GFileInfo.
* @attribute: a file attribute key.
@@ -600,7 +658,7 @@ g_file_info_get_attribute_object (GFileInfo *info,
g_return_val_if_fail (attribute != NULL && *attribute != '\0', NULL);
value = g_file_info_find_value_by_name (info, attribute);
- return g_file_attribute_value_get_object (value);
+ return _g_file_attribute_value_get_object (value);
}
/**
@@ -624,7 +682,7 @@ g_file_info_get_attribute_string (GFileInfo *info,
g_return_val_if_fail (attribute != NULL && *attribute != '\0', NULL);
value = g_file_info_find_value_by_name (info, attribute);
- return g_file_attribute_value_get_string (value);
+ return _g_file_attribute_value_get_string (value);
}
/**
@@ -648,7 +706,7 @@ g_file_info_get_attribute_byte_string (GFileInfo *info,
g_return_val_if_fail (attribute != NULL && *attribute != '\0', NULL);
value = g_file_info_find_value_by_name (info, attribute);
- return g_file_attribute_value_get_byte_string (value);
+ return _g_file_attribute_value_get_byte_string (value);
}
/**
@@ -671,7 +729,7 @@ g_file_info_get_attribute_boolean (GFileInfo *info,
g_return_val_if_fail (attribute != NULL && *attribute != '\0', FALSE);
value = g_file_info_find_value_by_name (info, attribute);
- return g_file_attribute_value_get_boolean (value);
+ return _g_file_attribute_value_get_boolean (value);
}
/**
@@ -695,7 +753,7 @@ g_file_info_get_attribute_uint32 (GFileInfo *info,
g_return_val_if_fail (attribute != NULL && *attribute != '\0', 0);
value = g_file_info_find_value_by_name (info, attribute);
- return g_file_attribute_value_get_uint32 (value);
+ return _g_file_attribute_value_get_uint32 (value);
}
/**
@@ -719,7 +777,7 @@ g_file_info_get_attribute_int32 (GFileInfo *info,
g_return_val_if_fail (attribute != NULL && *attribute != '\0', 0);
value = g_file_info_find_value_by_name (info, attribute);
- return g_file_attribute_value_get_int32 (value);
+ return _g_file_attribute_value_get_int32 (value);
}
/**
@@ -743,7 +801,7 @@ g_file_info_get_attribute_uint64 (GFileInfo *info,
g_return_val_if_fail (attribute != NULL && *attribute != '\0', 0);
value = g_file_info_find_value_by_name (info, attribute);
- return g_file_attribute_value_get_uint64 (value);
+ return _g_file_attribute_value_get_uint64 (value);
}
/**
@@ -767,7 +825,7 @@ g_file_info_get_attribute_int64 (GFileInfo *info,
g_return_val_if_fail (attribute != NULL && *attribute != '\0', 0);
value = g_file_info_find_value_by_name (info, attribute);
- return g_file_attribute_value_get_int64 (value);
+ return _g_file_attribute_value_get_int64 (value);
}
static GFileAttributeValue *
@@ -775,7 +833,6 @@ g_file_info_create_value (GFileInfo *info,
guint32 attr_id)
{
GFileAttribute *attrs;
- GFileAttribute attr;
int i;
if (info->mask != NO_ATTRIBUTE_MASK &&
@@ -790,8 +847,8 @@ g_file_info_create_value (GFileInfo *info,
return &attrs[i].value;
else
{
+ GFileAttribute attr = { 0 };
attr.attribute = attr_id;
- attr.value.type = G_FILE_ATTRIBUTE_TYPE_INVALID;
g_array_insert_val (info->attributes, i, attr);
attrs = (GFileAttribute *)info->attributes->data;
@@ -822,17 +879,18 @@ g_file_info_create_value_by_name (GFileInfo *info,
void
g_file_info_set_attribute (GFileInfo *info,
const char *attribute,
- const GFileAttributeValue *attr_value)
+ GFileAttributeType type,
+ gpointer value_p)
{
GFileAttributeValue *value;
g_return_if_fail (G_IS_FILE_INFO (info));
g_return_if_fail (attribute != NULL && *attribute != '\0');
- g_return_if_fail (attr_value != NULL);
value = g_file_info_create_value_by_name (info, attribute);
+
if (value)
- g_file_attribute_value_set (value, attr_value);
+ _g_file_attribute_value_set_from_pointer (value, type, value_p, TRUE);
}
/**
@@ -857,7 +915,7 @@ g_file_info_set_attribute_object (GFileInfo *info,
value = g_file_info_create_value_by_name (info, attribute);
if (value)
- g_file_attribute_value_set_object (value, attr_value);
+ _g_file_attribute_value_set_object (value, attr_value);
}
/**
@@ -882,7 +940,7 @@ g_file_info_set_attribute_string (GFileInfo *info,
value = g_file_info_create_value_by_name (info, attribute);
if (value)
- g_file_attribute_value_set_string (value, attr_value);
+ _g_file_attribute_value_set_string (value, attr_value);
}
/**
@@ -907,7 +965,7 @@ g_file_info_set_attribute_byte_string (GFileInfo *info,
value = g_file_info_create_value_by_name (info, attribute);
if (value)
- g_file_attribute_value_set_byte_string (value, attr_value);
+ _g_file_attribute_value_set_byte_string (value, attr_value);
}
/**
@@ -931,7 +989,7 @@ g_file_info_set_attribute_boolean (GFileInfo *info,
value = g_file_info_create_value_by_name (info, attribute);
if (value)
- g_file_attribute_value_set_boolean (value, attr_value);
+ _g_file_attribute_value_set_boolean (value, attr_value);
}
/**
@@ -955,7 +1013,7 @@ g_file_info_set_attribute_uint32 (GFileInfo *info,
value = g_file_info_create_value_by_name (info, attribute);
if (value)
- g_file_attribute_value_set_uint32 (value, attr_value);
+ _g_file_attribute_value_set_uint32 (value, attr_value);
}
@@ -980,7 +1038,7 @@ g_file_info_set_attribute_int32 (GFileInfo *info,
value = g_file_info_create_value_by_name (info, attribute);
if (value)
- g_file_attribute_value_set_int32 (value, attr_value);
+ _g_file_attribute_value_set_int32 (value, attr_value);
}
/**
@@ -1004,7 +1062,7 @@ g_file_info_set_attribute_uint64 (GFileInfo *info,
value = g_file_info_create_value_by_name (info, attribute);
if (value)
- g_file_attribute_value_set_uint64 (value, attr_value);
+ _g_file_attribute_value_set_uint64 (value, attr_value);
}
/**
@@ -1029,7 +1087,7 @@ g_file_info_set_attribute_int64 (GFileInfo *info,
value = g_file_info_create_value_by_name (info, attribute);
if (value)
- g_file_attribute_value_set_int64 (value, attr_value);
+ _g_file_attribute_value_set_int64 (value, attr_value);
}
/* Helper getters */
@@ -1054,7 +1112,7 @@ g_file_info_get_file_type (GFileInfo *info)
attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_TYPE);
value = g_file_info_find_value (info, attr);
- return (GFileType)g_file_attribute_value_get_uint32 (value);
+ return (GFileType)_g_file_attribute_value_get_uint32 (value);
}
/**
@@ -1077,7 +1135,7 @@ g_file_info_get_is_hidden (GFileInfo *info)
attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_IS_HIDDEN);
value = g_file_info_find_value (info, attr);
- return (GFileType)g_file_attribute_value_get_boolean (value);
+ return (GFileType)_g_file_attribute_value_get_boolean (value);
}
/**
@@ -1100,7 +1158,7 @@ g_file_info_get_is_backup (GFileInfo *info)
attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_IS_BACKUP);
value = g_file_info_find_value (info, attr);
- return (GFileType)g_file_attribute_value_get_boolean (value);
+ return (GFileType)_g_file_attribute_value_get_boolean (value);
}
/**
@@ -1123,7 +1181,7 @@ g_file_info_get_is_symlink (GFileInfo *info)
attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_IS_SYMLINK);
value = g_file_info_find_value (info, attr);
- return (GFileType)g_file_attribute_value_get_boolean (value);
+ return (GFileType)_g_file_attribute_value_get_boolean (value);
}
/**
@@ -1146,7 +1204,7 @@ g_file_info_get_name (GFileInfo *info)
attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_NAME);
value = g_file_info_find_value (info, attr);
- return g_file_attribute_value_get_byte_string (value);
+ return _g_file_attribute_value_get_byte_string (value);
}
/**
@@ -1169,7 +1227,7 @@ g_file_info_get_display_name (GFileInfo *info)
attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_DISPLAY_NAME);
value = g_file_info_find_value (info, attr);
- return g_file_attribute_value_get_string (value);
+ return _g_file_attribute_value_get_string (value);
}
/**
@@ -1192,7 +1250,7 @@ g_file_info_get_edit_name (GFileInfo *info)
attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_EDIT_NAME);
value = g_file_info_find_value (info, attr);
- return g_file_attribute_value_get_string (value);
+ return _g_file_attribute_value_get_string (value);
}
/**
@@ -1216,7 +1274,7 @@ g_file_info_get_icon (GFileInfo *info)
attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_ICON);
value = g_file_info_find_value (info, attr);
- obj = g_file_attribute_value_get_object (value);
+ obj = _g_file_attribute_value_get_object (value);
if (obj != NULL && G_IS_ICON (obj))
return G_ICON (obj);
return NULL;
@@ -1242,7 +1300,7 @@ g_file_info_get_content_type (GFileInfo *info)
attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_CONTENT_TYPE);
value = g_file_info_find_value (info, attr);
- return g_file_attribute_value_get_string (value);
+ return _g_file_attribute_value_get_string (value);
}
/**
@@ -1265,7 +1323,7 @@ g_file_info_get_size (GFileInfo *info)
attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_SIZE);
value = g_file_info_find_value (info, attr);
- return (goffset) g_file_attribute_value_get_uint64 (value);
+ return (goffset) _g_file_attribute_value_get_uint64 (value);
}
/**
@@ -1293,9 +1351,9 @@ g_file_info_get_modification_time (GFileInfo *info,
}
value = g_file_info_find_value (info, attr_mtime);
- result->tv_sec = g_file_attribute_value_get_uint64 (value);
+ result->tv_sec = _g_file_attribute_value_get_uint64 (value);
value = g_file_info_find_value (info, attr_mtime_usec);
- result->tv_usec = g_file_attribute_value_get_uint32 (value);
+ result->tv_usec = _g_file_attribute_value_get_uint32 (value);
}
/**
@@ -1318,7 +1376,7 @@ g_file_info_get_symlink_target (GFileInfo *info)
attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_SYMLINK_TARGET);
value = g_file_info_find_value (info, attr);
- return g_file_attribute_value_get_byte_string (value);
+ return _g_file_attribute_value_get_byte_string (value);
}
/**
@@ -1342,7 +1400,7 @@ g_file_info_get_etag (GFileInfo *info)
attr = lookup_attribute (G_FILE_ATTRIBUTE_ETAG_VALUE);
value = g_file_info_find_value (info, attr);
- return g_file_attribute_value_get_string (value);
+ return _g_file_attribute_value_get_string (value);
}
/**
@@ -1366,7 +1424,7 @@ g_file_info_get_sort_order (GFileInfo *info)
attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_SORT_ORDER);
value = g_file_info_find_value (info, attr);
- return g_file_attribute_value_get_int32 (value);
+ return _g_file_attribute_value_get_int32 (value);
}
/* Helper setters: */
@@ -1392,7 +1450,7 @@ g_file_info_set_file_type (GFileInfo *info,
value = g_file_info_create_value (info, attr);
if (value)
- g_file_attribute_value_set_uint32 (value, type);
+ _g_file_attribute_value_set_uint32 (value, type);
}
/**
@@ -1417,7 +1475,7 @@ g_file_info_set_is_hidden (GFileInfo *info,
value = g_file_info_create_value (info, attr);
if (value)
- g_file_attribute_value_set_boolean (value, is_hidden);
+ _g_file_attribute_value_set_boolean (value, is_hidden);
}
/**
@@ -1442,7 +1500,7 @@ g_file_info_set_is_symlink (GFileInfo *info,
value = g_file_info_create_value (info, attr);
if (value)
- g_file_attribute_value_set_boolean (value, is_symlink);
+ _g_file_attribute_value_set_boolean (value, is_symlink);
}
/**
@@ -1468,7 +1526,7 @@ g_file_info_set_name (GFileInfo *info,
value = g_file_info_create_value (info, attr);
if (value)
- g_file_attribute_value_set_byte_string (value, name);
+ _g_file_attribute_value_set_byte_string (value, name);
}
/**
@@ -1494,7 +1552,7 @@ g_file_info_set_display_name (GFileInfo *info,
value = g_file_info_create_value (info, attr);
if (value)
- g_file_attribute_value_set_string (value, display_name);
+ _g_file_attribute_value_set_string (value, display_name);
}
/**
@@ -1520,7 +1578,7 @@ g_file_info_set_edit_name (GFileInfo *info,
value = g_file_info_create_value (info, attr);
if (value)
- g_file_attribute_value_set_string (value, edit_name);
+ _g_file_attribute_value_set_string (value, edit_name);
}
/**
@@ -1546,7 +1604,7 @@ g_file_info_set_icon (GFileInfo *info,
value = g_file_info_create_value (info, attr);
if (value)
- g_file_attribute_value_set_object (value, G_OBJECT (icon));
+ _g_file_attribute_value_set_object (value, G_OBJECT (icon));
}
/**
@@ -1572,7 +1630,7 @@ g_file_info_set_content_type (GFileInfo *info,
value = g_file_info_create_value (info, attr);
if (value)
- g_file_attribute_value_set_string (value, content_type);
+ _g_file_attribute_value_set_string (value, content_type);
}
/**
@@ -1597,7 +1655,7 @@ g_file_info_set_size (GFileInfo *info,
value = g_file_info_create_value (info, attr);
if (value)
- g_file_attribute_value_set_uint64 (value, size);
+ _g_file_attribute_value_set_uint64 (value, size);
}
/**
@@ -1626,10 +1684,10 @@ g_file_info_set_modification_time (GFileInfo *info,
value = g_file_info_create_value (info, attr_mtime);
if (value)
- g_file_attribute_value_set_uint64 (value, mtime->tv_sec);
+ _g_file_attribute_value_set_uint64 (value, mtime->tv_sec);
value = g_file_info_create_value (info, attr_mtime_usec);
if (value)
- g_file_attribute_value_set_uint32 (value, mtime->tv_usec);
+ _g_file_attribute_value_set_uint32 (value, mtime->tv_usec);
}
/**
@@ -1655,7 +1713,7 @@ g_file_info_set_symlink_target (GFileInfo *info,
value = g_file_info_create_value (info, attr);
if (value)
- g_file_attribute_value_set_byte_string (value, symlink_target);
+ _g_file_attribute_value_set_byte_string (value, symlink_target);
}
/**
@@ -1680,7 +1738,7 @@ g_file_info_set_sort_order (GFileInfo *info,
value = g_file_info_create_value (info, attr);
if (value)
- g_file_attribute_value_set_int32 (value, sort_order);
+ _g_file_attribute_value_set_int32 (value, sort_order);
}
diff --git a/gio/gfileinfo.h b/gio/gfileinfo.h
index ec48d1e74..bcd23a883 100644
--- a/gio/gfileinfo.h
+++ b/gio/gfileinfo.h
@@ -683,11 +683,18 @@ gboolean g_file_info_has_attribute (GFileInfo *info,
const char *attribute);
char ** g_file_info_list_attributes (GFileInfo *info,
const char *name_space);
+gboolean g_file_info_get_attribute_data (GFileInfo *info,
+ const char *attribute,
+ GFileAttributeType *type,
+ gpointer *value_pp,
+ GFileAttributeStatus *status);
GFileAttributeType g_file_info_get_attribute_type (GFileInfo *info,
const char *attribute);
void g_file_info_remove_attribute (GFileInfo *info,
const char *attribute);
-GFileAttributeValue * g_file_info_get_attribute (GFileInfo *info,
+GFileAttributeStatus g_file_info_get_attribute_status (GFileInfo *info,
+ const char *attribute);
+char * g_file_info_get_attribute_as_string (GFileInfo *info,
const char *attribute);
const char * g_file_info_get_attribute_string (GFileInfo *info,
const char *attribute);
@@ -708,7 +715,8 @@ GObject * g_file_info_get_attribute_object (GFileInfo *info,
void g_file_info_set_attribute (GFileInfo *info,
const char *attribute,
- const GFileAttributeValue *attr_value);
+ GFileAttributeType type,
+ gpointer value_p);
void g_file_info_set_attribute_string (GFileInfo *info,
const char *attribute,
const char *attr_value);
diff --git a/gio/gio.symbols b/gio/gio.symbols
index 25cdfd61d..ea5bb51c7 100644
--- a/gio/gio.symbols
+++ b/gio/gio.symbols
@@ -65,6 +65,7 @@ g_app_info_get_default_for_uri_scheme
#if IN_FILE(__G_DESKTOP_APP_INFO_C__)
g_desktop_app_info_new_from_filename
g_desktop_app_info_new
+g_desktop_app_info_get_type G_GNUC_CONST
g_desktop_app_info_get_is_hidden
#endif
#endif
@@ -204,28 +205,6 @@ g_drive_poll_for_media_finish
#if IN_HEADER(__G_FILE_ATTRIBUTE_H__)
#if IN_FILE(__G_FILE_ATTRIBUTE_C__)
-g_file_attribute_value_new
-g_file_attribute_value_free
-g_file_attribute_value_clear
-g_file_attribute_value_set
-g_file_attribute_value_dup
-g_file_attribute_value_as_string
-g_file_attribute_value_get_string
-g_file_attribute_value_get_byte_string
-g_file_attribute_value_get_boolean
-g_file_attribute_value_get_uint32
-g_file_attribute_value_get_int32
-g_file_attribute_value_get_uint64
-g_file_attribute_value_get_int64
-g_file_attribute_value_get_object
-g_file_attribute_value_set_string
-g_file_attribute_value_set_byte_string
-g_file_attribute_value_set_boolean
-g_file_attribute_value_set_uint32
-g_file_attribute_value_set_int32
-g_file_attribute_value_set_uint64
-g_file_attribute_value_set_int64
-g_file_attribute_value_set_object
g_file_attribute_info_list_new
g_file_attribute_info_list_ref
g_file_attribute_info_list_unref
@@ -354,7 +333,9 @@ g_file_info_has_attribute
g_file_info_list_attributes
g_file_info_get_attribute_type
g_file_info_remove_attribute
-g_file_info_get_attribute
+g_file_info_get_attribute_status
+g_file_info_get_attribute_data
+g_file_info_get_attribute_as_string
g_file_info_get_attribute_string
g_file_info_get_attribute_byte_string
g_file_info_get_attribute_boolean
diff --git a/gio/glocalfile.c b/gio/glocalfile.c
index d26e3819a..2d981a55f 100644
--- a/gio/glocalfile.c
+++ b/gio/glocalfile.c
@@ -1020,7 +1020,8 @@ g_local_file_query_writable_namespaces (GFile *file,
static gboolean
g_local_file_set_attribute (GFile *file,
const char *attribute,
- const GFileAttributeValue *value,
+ GFileAttributeType type,
+ gpointer value_p,
GFileQueryInfoFlags flags,
GCancellable *cancellable,
GError **error)
@@ -1029,7 +1030,8 @@ g_local_file_set_attribute (GFile *file,
return _g_local_file_info_set_attribute (local->filename,
attribute,
- value,
+ type,
+ value_p,
flags,
cancellable,
error);
diff --git a/gio/glocalfileinfo.c b/gio/glocalfileinfo.c
index 5b11b7f45..afe6e4053 100644
--- a/gio/glocalfileinfo.c
+++ b/gio/glocalfileinfo.c
@@ -57,6 +57,7 @@
#include <glib/gstdio.h>
#include <glib/gchecksum.h>
+#include <gfileattribute-priv.h>
#include "glibintl.h"
@@ -1939,42 +1940,47 @@ set_mtime_atime (char *filename,
gboolean
_g_local_file_info_set_attribute (char *filename,
const char *attribute,
- const GFileAttributeValue *value,
+ GFileAttributeType type,
+ gpointer value_p,
GFileQueryInfoFlags flags,
GCancellable *cancellable,
GError **error)
{
+ GFileAttributeValue value = { 0 };
+
+ _g_file_attribute_value_set_from_pointer (&value, type, value_p, FALSE);
+
if (strcmp (attribute, G_FILE_ATTRIBUTE_UNIX_MODE) == 0)
- return set_unix_mode (filename, value, error);
+ return set_unix_mode (filename, &value, error);
#ifdef HAVE_CHOWN
else if (strcmp (attribute, G_FILE_ATTRIBUTE_UNIX_UID) == 0)
- return set_unix_uid_gid (filename, value, NULL, flags, error);
+ return set_unix_uid_gid (filename, &value, NULL, flags, error);
else if (strcmp (attribute, G_FILE_ATTRIBUTE_UNIX_GID) == 0)
- return set_unix_uid_gid (filename, NULL, value, flags, error);
+ return set_unix_uid_gid (filename, NULL, &value, flags, error);
#endif
#ifdef HAVE_SYMLINK
else if (strcmp (attribute, G_FILE_ATTRIBUTE_STD_SYMLINK_TARGET) == 0)
- return set_symlink (filename, value, error);
+ return set_symlink (filename, &value, error);
#endif
#ifdef HAVE_UTIMES
else if (strcmp (attribute, G_FILE_ATTRIBUTE_TIME_MODIFIED) == 0)
- return set_mtime_atime (filename, value, NULL, NULL, NULL, error);
+ return set_mtime_atime (filename, &value, NULL, NULL, NULL, error);
else if (strcmp (attribute, G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC) == 0)
- return set_mtime_atime (filename, NULL, value, NULL, NULL, error);
+ return set_mtime_atime (filename, NULL, &value, NULL, NULL, error);
else if (strcmp (attribute, G_FILE_ATTRIBUTE_TIME_ACCESS) == 0)
- return set_mtime_atime (filename, NULL, NULL, value, NULL, error);
+ return set_mtime_atime (filename, NULL, NULL, &value, NULL, error);
else if (strcmp (attribute, G_FILE_ATTRIBUTE_TIME_ACCESS_USEC) == 0)
- return set_mtime_atime (filename, NULL, NULL, NULL, value, error);
+ return set_mtime_atime (filename, NULL, NULL, NULL, &value, error);
#endif
#ifdef HAVE_XATTR
else if (g_str_has_prefix (attribute, "xattr::"))
- return set_xattr (filename, attribute, value, error);
+ return set_xattr (filename, attribute, &value, error);
else if (g_str_has_prefix (attribute, "xattr-sys::"))
- return set_xattr (filename, attribute, value, error);
+ return set_xattr (filename, attribute, &value, error);
#endif
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
@@ -2001,7 +2007,7 @@ _g_local_file_info_set_attributes (char *filename,
/* Set symlink first, since this recreates the file */
#ifdef HAVE_SYMLINK
- value = g_file_info_get_attribute (info, G_FILE_ATTRIBUTE_STD_SYMLINK_TARGET);
+ value = _g_file_info_get_attribute_value (info, G_FILE_ATTRIBUTE_STD_SYMLINK_TARGET);
if (value)
{
if (!set_symlink (filename, value, error))
@@ -2022,8 +2028,8 @@ _g_local_file_info_set_attributes (char *filename,
* Change ownership before permissions, since ownership changes can
change permissions (e.g. setuid)
*/
- uid = g_file_info_get_attribute (info, G_FILE_ATTRIBUTE_UNIX_UID);
- gid = g_file_info_get_attribute (info, G_FILE_ATTRIBUTE_UNIX_GID);
+ uid = _g_file_info_get_attribute_value (info, G_FILE_ATTRIBUTE_UNIX_UID);
+ gid = _g_file_info_get_attribute_value (info, G_FILE_ATTRIBUTE_UNIX_GID);
if (uid || gid)
{
@@ -2043,7 +2049,7 @@ _g_local_file_info_set_attributes (char *filename,
}
#endif
- value = g_file_info_get_attribute (info, G_FILE_ATTRIBUTE_UNIX_MODE);
+ value = _g_file_info_get_attribute_value (info, G_FILE_ATTRIBUTE_UNIX_MODE);
if (value)
{
if (!set_unix_mode (filename, value, error))
@@ -2063,10 +2069,10 @@ _g_local_file_info_set_attributes (char *filename,
* Change times as the last thing to avoid it changing due to metadata changes
*/
- mtime = g_file_info_get_attribute (info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
- mtime_usec = g_file_info_get_attribute (info, G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC);
- atime = g_file_info_get_attribute (info, G_FILE_ATTRIBUTE_TIME_ACCESS);
- atime_usec = g_file_info_get_attribute (info, G_FILE_ATTRIBUTE_TIME_ACCESS_USEC);
+ mtime = _g_file_info_get_attribute_value (info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
+ mtime_usec = _g_file_info_get_attribute_value (info, G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC);
+ atime = _g_file_info_get_attribute_value (info, G_FILE_ATTRIBUTE_TIME_ACCESS);
+ atime_usec = _g_file_info_get_attribute_value (info, G_FILE_ATTRIBUTE_TIME_ACCESS_USEC);
if (mtime || mtime_usec || atime || atime_usec)
{
diff --git a/gio/glocalfileinfo.h b/gio/glocalfileinfo.h
index bcb1d16ec..19999accb 100644
--- a/gio/glocalfileinfo.h
+++ b/gio/glocalfileinfo.h
@@ -54,7 +54,8 @@ GFileInfo *_g_local_file_info_get_from_fd (int fd,
char * _g_local_file_info_create_etag (struct stat *statbuf);
gboolean _g_local_file_info_set_attribute (char *filename,
const char *attribute,
- const GFileAttributeValue *value,
+ GFileAttributeType type,
+ gpointer value_p,
GFileQueryInfoFlags flags,
GCancellable *cancellable,
GError **error);
diff --git a/gio/gunixmounts.c b/gio/gunixmounts.c
index 51db6dc4d..61ca2cf44 100644
--- a/gio/gunixmounts.c
+++ b/gio/gunixmounts.c
@@ -63,7 +63,7 @@ static const char *_resolve_dev_root (void);
*
**/
-/**
+/*
* GUnixMountType:
* @G_UNIX_MOUNT_TYPE_UNKNOWN: Unknown UNIX mount type.
* @G_UNIX_MOUNT_TYPE_FLOPPY: Floppy disk UNIX mount type.
@@ -1622,7 +1622,7 @@ guess_mount_type (const char *mount_path,
return type;
}
-/**
+/*
* g_unix_mount_guess_type:
* @mount_entry: a #GUnixMount.
*
@@ -1631,7 +1631,7 @@ guess_mount_type (const char *mount_path,
*
* Returns: a #GUnixMountType.
**/
-GUnixMountType
+static GUnixMountType
g_unix_mount_guess_type (GUnixMountEntry *mount_entry)
{
g_return_val_if_fail (mount_entry != NULL, G_UNIX_MOUNT_TYPE_UNKNOWN);
@@ -1644,7 +1644,7 @@ g_unix_mount_guess_type (GUnixMountEntry *mount_entry)
mount_entry->filesystem_type);
}
-/**
+/*
* g_unix_mount_point_guess_type:
* @mount_point: a #GUnixMountPoint.
*
@@ -1653,7 +1653,7 @@ g_unix_mount_guess_type (GUnixMountEntry *mount_entry)
*
* Returns: a #GUnixMountType.
**/
-GUnixMountType
+static GUnixMountType
g_unix_mount_point_guess_type (GUnixMountPoint *mount_point)
{
g_return_val_if_fail (mount_point != NULL, G_UNIX_MOUNT_TYPE_UNKNOWN);