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
This commit is contained in:
Alexander Larsson 2007-12-14 15:56:56 +00:00 committed by Alexander Larsson
parent 2ceae92eeb
commit f506365079
14 changed files with 455 additions and 282 deletions

View File

@ -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> 2007-12-14 Yevgen Muntyan <muntyan@tamu.edu>
* Makefile.am: * Makefile.am:

View File

@ -141,6 +141,7 @@ libgio_2_0_la_SOURCES = \
gdummyfile.c \ gdummyfile.c \
gfile.c \ gfile.c \
gfileattribute.c \ gfileattribute.c \
gfileattribute-priv.h \
gfileenumerator.c \ gfileenumerator.c \
gfileicon.c \ gfileicon.c \
gfileinfo.c \ gfileinfo.c \

View File

@ -31,6 +31,7 @@
#include "gioscheduler.h" #include "gioscheduler.h"
#include <glocalfile.h> #include <glocalfile.h>
#include "gsimpleasyncresult.h" #include "gsimpleasyncresult.h"
#include "gfileattribute-priv.h"
#include "gpollfilemonitor.h" #include "gpollfilemonitor.h"
#include "glibintl.h" #include "glibintl.h"
@ -2566,7 +2567,8 @@ g_file_query_writable_namespaces (GFile *file,
* g_file_set_attribute: * g_file_set_attribute:
* @file: input #GFile. * @file: input #GFile.
* @attribute: a string containing the attribute's name. * @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. * @flags: a set of #GFileQueryInfoFlags.
* @cancellable: optional #GCancellable object, %NULL to ignore. * @cancellable: optional #GCancellable object, %NULL to ignore.
* @error: a #GError, or %NULL * @error: a #GError, or %NULL
@ -2582,7 +2584,8 @@ g_file_query_writable_namespaces (GFile *file,
gboolean gboolean
g_file_set_attribute (GFile *file, g_file_set_attribute (GFile *file,
const char *attribute, const char *attribute,
const GFileAttributeValue *value, GFileAttributeType type,
gpointer value_p,
GFileQueryInfoFlags flags, GFileQueryInfoFlags flags,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
@ -2605,7 +2608,7 @@ g_file_set_attribute (GFile *file,
return FALSE; 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++) 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) if (value->status != G_FILE_ATTRIBUTE_STATUS_UNSET)
continue; 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; value->status = G_FILE_ATTRIBUTE_STATUS_ERROR_SETTING;
res = FALSE; res = FALSE;
@ -2790,11 +2795,9 @@ g_file_set_attribute_string (GFile *file,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
GFileAttributeValue v; return g_file_set_attribute (file, attribute,
G_FILE_ATTRIBUTE_TYPE_STRING, (gpointer)value,
v.type = G_FILE_ATTRIBUTE_TYPE_STRING; flags, cancellable, error);
v.u.string = (char *)value;
return g_file_set_attribute (file, attribute, &v, flags, cancellable, error);
} }
/** /**
@ -2825,11 +2828,9 @@ g_file_set_attribute_byte_string (GFile *file,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
GFileAttributeValue v; return g_file_set_attribute (file, attribute,
G_FILE_ATTRIBUTE_TYPE_BYTE_STRING, (gpointer)value,
v.type = G_FILE_ATTRIBUTE_TYPE_BYTE_STRING; flags, cancellable, error);
v.u.string = (char *)value;
return g_file_set_attribute (file, attribute, &v, flags, cancellable, error);
} }
/** /**
@ -2859,11 +2860,9 @@ g_file_set_attribute_uint32 (GFile *file,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
GFileAttributeValue v; return g_file_set_attribute (file, attribute,
G_FILE_ATTRIBUTE_TYPE_UINT32, &value,
v.type = G_FILE_ATTRIBUTE_TYPE_UINT32; flags, cancellable, error);
v.u.uint32 = value;
return g_file_set_attribute (file, attribute, &v, flags, cancellable, error);
} }
/** /**
@ -2893,11 +2892,9 @@ g_file_set_attribute_int32 (GFile *file,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
GFileAttributeValue v; return g_file_set_attribute (file, attribute,
G_FILE_ATTRIBUTE_TYPE_INT32, &value,
v.type = G_FILE_ATTRIBUTE_TYPE_INT32; flags, cancellable, error);
v.u.int32 = value;
return g_file_set_attribute (file, attribute, &v, flags, cancellable, error);
} }
/** /**
@ -2927,11 +2924,9 @@ g_file_set_attribute_uint64 (GFile *file,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
GFileAttributeValue v; return g_file_set_attribute (file, attribute,
G_FILE_ATTRIBUTE_TYPE_UINT64, &value,
v.type = G_FILE_ATTRIBUTE_TYPE_UINT64; flags, cancellable, error);
v.u.uint64 = value;
return g_file_set_attribute (file, attribute, &v, flags, cancellable, error);
} }
/** /**
@ -2960,11 +2955,9 @@ g_file_set_attribute_int64 (GFile *file,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
GFileAttributeValue v; return g_file_set_attribute (file, attribute,
G_FILE_ATTRIBUTE_TYPE_INT64, &value,
v.type = G_FILE_ATTRIBUTE_TYPE_INT64; flags, cancellable, error);
v.u.int64 = value;
return g_file_set_attribute (file, attribute, &v, flags, cancellable, error);
} }
/** /**

View File

@ -341,7 +341,8 @@ struct _GFileIface
gboolean (*set_attribute) (GFile *file, gboolean (*set_attribute) (GFile *file,
const char *attribute, const char *attribute,
const GFileAttributeValue *value, GFileAttributeType type,
gpointer value_p,
GFileQueryInfoFlags flags, GFileQueryInfoFlags flags,
GCancellable *cancellable, GCancellable *cancellable,
GError **error); GError **error);
@ -679,7 +680,8 @@ GFileAttributeInfoList *g_file_query_writable_namespaces (GFile
GError **error); GError **error);
gboolean g_file_set_attribute (GFile *file, gboolean g_file_set_attribute (GFile *file,
const char *attribute, const char *attribute,
const GFileAttributeValue *value, GFileAttributeType type,
gpointer value_p,
GFileQueryInfoFlags flags, GFileQueryInfoFlags flags,
GCancellable *cancellable, GCancellable *cancellable,
GError **error); GError **error);

89
gio/gfileattribute-priv.h Normal file
View File

@ -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__ */

View File

@ -25,6 +25,7 @@
#include <string.h> #include <string.h>
#include "gfileattribute.h" #include "gfileattribute.h"
#include "gfileattribute-priv.h"
#include <glib-object.h> #include <glib-object.h>
#include "glibintl.h" #include "glibintl.h"
@ -184,24 +185,24 @@
* *
**/ **/
/** /*
* g_file_attribute_value_free: * _g_file_attribute_value_free:
* @attr: a #GFileAttributeValue. * @attr: a #GFileAttributeValue.
* *
* Frees the memory used by @attr. * Frees the memory used by @attr.
* *
**/ **/
void void
g_file_attribute_value_free (GFileAttributeValue *attr) _g_file_attribute_value_free (GFileAttributeValue *attr)
{ {
g_return_if_fail (attr != NULL); g_return_if_fail (attr != NULL);
g_file_attribute_value_clear (attr); _g_file_attribute_value_clear (attr);
g_free (attr); g_free (attr);
} }
/** /*
* g_file_attribute_value_clear: * _g_file_attribute_value_clear:
* @attr: a #GFileAttributeValue. * @attr: a #GFileAttributeValue.
* *
* Clears the value of @attr and sets its type to * Clears the value of @attr and sets its type to
@ -209,7 +210,7 @@ g_file_attribute_value_free (GFileAttributeValue *attr)
* *
**/ **/
void void
g_file_attribute_value_clear (GFileAttributeValue *attr) _g_file_attribute_value_clear (GFileAttributeValue *attr)
{ {
g_return_if_fail (attr != NULL); g_return_if_fail (attr != NULL);
@ -224,7 +225,7 @@ g_file_attribute_value_clear (GFileAttributeValue *attr)
attr->type = G_FILE_ATTRIBUTE_TYPE_INVALID; attr->type = G_FILE_ATTRIBUTE_TYPE_INVALID;
} }
/** /*
* g_file_attribute_value_set: * g_file_attribute_value_set:
* @attr: a #GFileAttributeValue to set the value in. * @attr: a #GFileAttributeValue to set the value in.
* @new_value: a #GFileAttributeValue to get the value from. * @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. * Sets an attribute's value from another attribute.
**/ **/
void void
g_file_attribute_value_set (GFileAttributeValue *attr, _g_file_attribute_value_set (GFileAttributeValue *attr,
const GFileAttributeValue *new_value) const GFileAttributeValue *new_value)
{ {
g_return_if_fail (attr != NULL); g_return_if_fail (attr != NULL);
g_return_if_fail (new_value != NULL); g_return_if_fail (new_value != NULL);
g_file_attribute_value_clear (attr); _g_file_attribute_value_clear (attr);
*attr = *new_value; *attr = *new_value;
if (attr->type == G_FILE_ATTRIBUTE_TYPE_STRING || 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_object_ref (attr->u.obj);
} }
/** /*
* g_file_attribute_value_new: * _g_file_attribute_value_new:
* *
* Creates a new file attribute. * Creates a new file attribute.
* *
* Returns: a #GFileAttributeValue. * Returns: a #GFileAttributeValue.
**/ **/
GFileAttributeValue * GFileAttributeValue *
g_file_attribute_value_new (void) _g_file_attribute_value_new (void)
{ {
GFileAttributeValue *attr; GFileAttributeValue *attr;
@ -267,8 +268,21 @@ g_file_attribute_value_new (void)
return attr; 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: * g_file_attribute_value_dup:
* @other: a #GFileAttributeValue to duplicate. * @other: a #GFileAttributeValue to duplicate.
* *
@ -277,7 +291,7 @@ g_file_attribute_value_new (void)
* Returns: a duplicate of the @other. * Returns: a duplicate of the @other.
**/ **/
GFileAttributeValue * GFileAttributeValue *
g_file_attribute_value_dup (const GFileAttributeValue *other) _g_file_attribute_value_dup (const GFileAttributeValue *other)
{ {
GFileAttributeValue *attr; GFileAttributeValue *attr;
@ -285,7 +299,7 @@ g_file_attribute_value_dup (const GFileAttributeValue *other)
attr = g_new (GFileAttributeValue, 1); attr = g_new (GFileAttributeValue, 1);
attr->type = G_FILE_ATTRIBUTE_TYPE_INVALID; attr->type = G_FILE_ATTRIBUTE_TYPE_INVALID;
g_file_attribute_value_set (attr, other); _g_file_attribute_value_set (attr, other);
return attr; return attr;
} }
@ -338,7 +352,7 @@ escape_byte_string (const char *str)
} }
} }
/** /*
* g_file_attribute_value_as_string: * g_file_attribute_value_as_string:
* @attr: a #GFileAttributeValue. * @attr: a #GFileAttributeValue.
* *
@ -349,7 +363,7 @@ escape_byte_string (const char *str)
* if @attr is of type %G_FILE_ATTRIBUTE_TYPE_INVALID. * if @attr is of type %G_FILE_ATTRIBUTE_TYPE_INVALID.
**/ **/
char * char *
g_file_attribute_value_as_string (const GFileAttributeValue *attr) _g_file_attribute_value_as_string (const GFileAttributeValue *attr)
{ {
char *str; char *str;
@ -392,7 +406,7 @@ g_file_attribute_value_as_string (const GFileAttributeValue *attr)
return str; return str;
} }
/** /*
* g_file_attribute_value_get_string: * g_file_attribute_value_get_string:
* @attr: a #GFileAttributeValue. * @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. * Returns: the string value contained within the attribute, or %NULL.
**/ **/
const char * const char *
g_file_attribute_value_get_string (const GFileAttributeValue *attr) _g_file_attribute_value_get_string (const GFileAttributeValue *attr)
{ {
if (attr == NULL) if (attr == NULL)
return NULL; return NULL;
@ -412,7 +426,7 @@ g_file_attribute_value_get_string (const GFileAttributeValue *attr)
return attr->u.string; return attr->u.string;
} }
/** /*
* g_file_attribute_value_get_byte_string: * g_file_attribute_value_get_byte_string:
* @attr: a #GFileAttributeValue. * @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. * Returns: the byte string contained within the attribute or %NULL.
**/ **/
const char * 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) if (attr == NULL)
return NULL; return NULL;
@ -432,7 +446,7 @@ g_file_attribute_value_get_byte_string (const GFileAttributeValue *attr)
return attr->u.string; return attr->u.string;
} }
/** /*
* g_file_attribute_value_get_boolean: * g_file_attribute_value_get_boolean:
* @attr: a #GFileAttributeValue. * @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. * Returns: the boolean value contained within the attribute, or %FALSE.
**/ **/
gboolean gboolean
g_file_attribute_value_get_boolean (const GFileAttributeValue *attr) _g_file_attribute_value_get_boolean (const GFileAttributeValue *attr)
{ {
if (attr == NULL) if (attr == NULL)
return FALSE; return FALSE;
@ -452,7 +466,7 @@ g_file_attribute_value_get_boolean (const GFileAttributeValue *attr)
return attr->u.boolean; return attr->u.boolean;
} }
/** /*
* g_file_attribute_value_get_uint32: * g_file_attribute_value_get_uint32:
* @attr: a #GFileAttributeValue. * @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. * Returns: the unsigned 32-bit integer from the attribute, or %0.
**/ **/
guint32 guint32
g_file_attribute_value_get_uint32 (const GFileAttributeValue *attr) _g_file_attribute_value_get_uint32 (const GFileAttributeValue *attr)
{ {
if (attr == NULL) if (attr == NULL)
return 0; return 0;
@ -472,7 +486,7 @@ g_file_attribute_value_get_uint32 (const GFileAttributeValue *attr)
return attr->u.uint32; return attr->u.uint32;
} }
/** /*
* g_file_attribute_value_get_int32: * g_file_attribute_value_get_int32:
* @attr: a #GFileAttributeValue. * @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. * Returns: the signed 32-bit integer from the attribute, or %0.
**/ **/
gint32 gint32
g_file_attribute_value_get_int32 (const GFileAttributeValue *attr) _g_file_attribute_value_get_int32 (const GFileAttributeValue *attr)
{ {
if (attr == NULL) if (attr == NULL)
return 0; return 0;
@ -492,7 +506,7 @@ g_file_attribute_value_get_int32 (const GFileAttributeValue *attr)
return attr->u.int32; return attr->u.int32;
} }
/** /*
* g_file_attribute_value_get_uint64: * g_file_attribute_value_get_uint64:
* @attr: a #GFileAttributeValue. * @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. * Returns: the unsigned 64-bit integer from the attribute, or %0.
**/ **/
guint64 guint64
g_file_attribute_value_get_uint64 (const GFileAttributeValue *attr) _g_file_attribute_value_get_uint64 (const GFileAttributeValue *attr)
{ {
if (attr == NULL) if (attr == NULL)
return 0; return 0;
@ -512,7 +526,7 @@ g_file_attribute_value_get_uint64 (const GFileAttributeValue *attr)
return attr->u.uint64; return attr->u.uint64;
} }
/** /*
* g_file_attribute_value_get_int64: * g_file_attribute_value_get_int64:
* @attr: a #GFileAttributeValue. * @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. * Returns: the signed 64-bit integer from the attribute, or %0.
**/ **/
gint64 gint64
g_file_attribute_value_get_int64 (const GFileAttributeValue *attr) _g_file_attribute_value_get_int64 (const GFileAttributeValue *attr)
{ {
if (attr == NULL) if (attr == NULL)
return 0; return 0;
@ -532,7 +546,7 @@ g_file_attribute_value_get_int64 (const GFileAttributeValue *attr)
return attr->u.int64; return attr->u.int64;
} }
/** /*
* g_file_attribute_value_get_object: * g_file_attribute_value_get_object:
* @attr: a #GFileAttributeValue. * @attr: a #GFileAttributeValue.
* *
@ -542,7 +556,7 @@ g_file_attribute_value_get_int64 (const GFileAttributeValue *attr)
* Returns: the GObject from the attribute, or %0. * Returns: the GObject from the attribute, or %0.
**/ **/
GObject * GObject *
g_file_attribute_value_get_object (const GFileAttributeValue *attr) _g_file_attribute_value_get_object (const GFileAttributeValue *attr)
{ {
if (attr == NULL) if (attr == NULL)
return NULL; return NULL;
@ -552,7 +566,58 @@ g_file_attribute_value_get_object (const GFileAttributeValue *attr)
return attr->u.obj; 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: * g_file_attribute_value_set_string:
* @attr: a #GFileAttributeValue. * @attr: a #GFileAttributeValue.
* @string: a string to set within the type. * @string: a string to set within the type.
@ -561,18 +626,18 @@ g_file_attribute_value_get_object (const GFileAttributeValue *attr)
* *
**/ **/
void void
g_file_attribute_value_set_string (GFileAttributeValue *attr, _g_file_attribute_value_set_string (GFileAttributeValue *attr,
const char *string) const char *string)
{ {
g_return_if_fail (attr != NULL); g_return_if_fail (attr != NULL);
g_return_if_fail (string != 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->type = G_FILE_ATTRIBUTE_TYPE_STRING;
attr->u.string = g_strdup (string); attr->u.string = g_strdup (string);
} }
/** /*
* g_file_attribute_value_set_byte_string: * g_file_attribute_value_set_byte_string:
* @attr: a #GFileAttributeValue. * @attr: a #GFileAttributeValue.
* @string: a byte string to set within the type. * @string: a byte string to set within the type.
@ -581,18 +646,18 @@ g_file_attribute_value_set_string (GFileAttributeValue *attr,
* *
**/ **/
void void
g_file_attribute_value_set_byte_string (GFileAttributeValue *attr, _g_file_attribute_value_set_byte_string (GFileAttributeValue *attr,
const char *string) const char *string)
{ {
g_return_if_fail (attr != NULL); g_return_if_fail (attr != NULL);
g_return_if_fail (string != 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->type = G_FILE_ATTRIBUTE_TYPE_BYTE_STRING;
attr->u.string = g_strdup (string); attr->u.string = g_strdup (string);
} }
/** /*
* g_file_attribute_value_set_boolean: * g_file_attribute_value_set_boolean:
* @attr: a #GFileAttributeValue. * @attr: a #GFileAttributeValue.
* @value: a #gboolean to set within the type. * @value: a #gboolean to set within the type.
@ -601,17 +666,17 @@ g_file_attribute_value_set_byte_string (GFileAttributeValue *attr,
* *
**/ **/
void void
g_file_attribute_value_set_boolean (GFileAttributeValue *attr, _g_file_attribute_value_set_boolean (GFileAttributeValue *attr,
gboolean value) gboolean value)
{ {
g_return_if_fail (attr != NULL); 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->type = G_FILE_ATTRIBUTE_TYPE_BOOLEAN;
attr->u.boolean = !!value; attr->u.boolean = !!value;
} }
/** /*
* g_file_attribute_value_set_uint32: * g_file_attribute_value_set_uint32:
* @attr: a #GFileAttributeValue. * @attr: a #GFileAttributeValue.
* @value: a #guint32 to set within the type. * @value: a #guint32 to set within the type.
@ -620,17 +685,17 @@ g_file_attribute_value_set_boolean (GFileAttributeValue *attr,
* *
**/ **/
void void
g_file_attribute_value_set_uint32 (GFileAttributeValue *attr, _g_file_attribute_value_set_uint32 (GFileAttributeValue *attr,
guint32 value) guint32 value)
{ {
g_return_if_fail (attr != NULL); 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->type = G_FILE_ATTRIBUTE_TYPE_UINT32;
attr->u.uint32 = value; attr->u.uint32 = value;
} }
/** /*
* g_file_attribute_value_set_int32: * g_file_attribute_value_set_int32:
* @attr: a #GFileAttributeValue. * @attr: a #GFileAttributeValue.
* @value: a #gint32 to set within the type. * @value: a #gint32 to set within the type.
@ -639,17 +704,17 @@ g_file_attribute_value_set_uint32 (GFileAttributeValue *attr,
* *
**/ **/
void void
g_file_attribute_value_set_int32 (GFileAttributeValue *attr, _g_file_attribute_value_set_int32 (GFileAttributeValue *attr,
gint32 value) gint32 value)
{ {
g_return_if_fail (attr != NULL); 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->type = G_FILE_ATTRIBUTE_TYPE_INT32;
attr->u.int32 = value; attr->u.int32 = value;
} }
/** /*
* g_file_attribute_value_set_uint64: * g_file_attribute_value_set_uint64:
* @attr: a #GFileAttributeValue. * @attr: a #GFileAttributeValue.
* @value: a #guint64 to set within the type. * @value: a #guint64 to set within the type.
@ -658,17 +723,17 @@ g_file_attribute_value_set_int32 (GFileAttributeValue *attr,
* *
**/ **/
void void
g_file_attribute_value_set_uint64 (GFileAttributeValue *attr, _g_file_attribute_value_set_uint64 (GFileAttributeValue *attr,
guint64 value) guint64 value)
{ {
g_return_if_fail (attr != NULL); 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->type = G_FILE_ATTRIBUTE_TYPE_UINT64;
attr->u.uint64 = value; attr->u.uint64 = value;
} }
/** /*
* g_file_attribute_value_set_int64: * g_file_attribute_value_set_int64:
* @attr: a #GFileAttributeValue. * @attr: a #GFileAttributeValue.
* @value: a #gint64 to set within the type. * @value: a #gint64 to set within the type.
@ -677,17 +742,17 @@ g_file_attribute_value_set_uint64 (GFileAttributeValue *attr,
* *
**/ **/
void void
g_file_attribute_value_set_int64 (GFileAttributeValue *attr, _g_file_attribute_value_set_int64 (GFileAttributeValue *attr,
gint64 value) gint64 value)
{ {
g_return_if_fail (attr != NULL); 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->type = G_FILE_ATTRIBUTE_TYPE_INT64;
attr->u.int64 = value; attr->u.int64 = value;
} }
/** /*
* g_file_attribute_value_set_object: * g_file_attribute_value_set_object:
* @attr: a #GFileAttributeValue. * @attr: a #GFileAttributeValue.
* @obj: a #GObject. * @obj: a #GObject.
@ -697,13 +762,13 @@ g_file_attribute_value_set_int64 (GFileAttributeValue *attr,
* *
**/ **/
void void
g_file_attribute_value_set_object (GFileAttributeValue *attr, _g_file_attribute_value_set_object (GFileAttributeValue *attr,
GObject *obj) GObject *obj)
{ {
g_return_if_fail (attr != NULL); g_return_if_fail (attr != NULL);
g_return_if_fail (obj != 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->type = G_FILE_ATTRIBUTE_TYPE_OBJECT;
attr->u.obj = g_object_ref (obj); attr->u.obj = g_object_ref (obj);
} }

View File

@ -85,30 +85,6 @@ typedef enum {
G_FILE_ATTRIBUTE_STATUS_ERROR_SETTING G_FILE_ATTRIBUTE_STATUS_ERROR_SETTING
} GFileAttributeStatus; } 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: * GFileAttributeInfo:
* @name: the name of the attribute. * @name: the name of the attribute.
@ -136,41 +112,6 @@ typedef struct {
int n_infos; int n_infos;
} GFileAttributeInfoList; } 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_new (void);
GFileAttributeInfoList * g_file_attribute_info_list_ref (GFileAttributeInfoList *list); GFileAttributeInfoList * g_file_attribute_info_list_ref (GFileAttributeInfoList *list);
void g_file_attribute_info_list_unref (GFileAttributeInfoList *list); void g_file_attribute_info_list_unref (GFileAttributeInfoList *list);

View File

@ -40,6 +40,7 @@
#include <string.h> #include <string.h>
#include "gfileinfo.h" #include "gfileinfo.h"
#include "gfileattribute-priv.h"
#include "glibintl.h" #include "glibintl.h"
#include "gioalias.h" #include "gioalias.h"
@ -65,6 +66,7 @@ struct _GFileInfoClass
GObjectClass parent_class; GObjectClass parent_class;
}; };
static gboolean g_file_attribute_matcher_matches_id (GFileAttributeMatcher *matcher, static gboolean g_file_attribute_matcher_matches_id (GFileAttributeMatcher *matcher,
guint32 id); guint32 id);
@ -210,7 +212,7 @@ g_file_info_finalize (GObject *object)
attrs = (GFileAttribute *)info->attributes->data; attrs = (GFileAttribute *)info->attributes->data;
for (i = 0; i < info->attributes->len; i++) 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); g_array_free (info->attributes, TRUE);
if (info->mask != NO_ATTRIBUTE_MASK) if (info->mask != NO_ATTRIBUTE_MASK)
@ -268,7 +270,7 @@ g_file_info_copy_into (GFileInfo *src_info,
dest = (GFileAttribute *)dest_info->attributes->data; dest = (GFileAttribute *)dest_info->attributes->data;
for (i = 0; i < dest_info->attributes->len; i++) 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, g_array_set_size (dest_info->attributes,
src_info->attributes->len); src_info->attributes->len);
@ -280,7 +282,7 @@ g_file_info_copy_into (GFileInfo *src_info,
{ {
dest[i].attribute = source[i].attribute; dest[i].attribute = source[i].attribute;
dest[i].value.type = G_FILE_ATTRIBUTE_TYPE_INVALID; 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) 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, if (!g_file_attribute_matcher_matches_id (mask,
attr->attribute)) attr->attribute))
{ {
g_file_attribute_value_clear (&attr->value); _g_file_attribute_value_clear (&attr->value);
g_array_remove_index (info->attributes, i); g_array_remove_index (info->attributes, i);
i--; i--;
} }
@ -553,23 +555,55 @@ g_file_info_remove_attribute (GFileInfo *info,
if (i < info->attributes->len && if (i < info->attributes->len &&
attrs[i].attribute == attr_id) 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_array_remove_index (info->attributes, i);
} }
} }
/** gboolean
* g_file_info_get_attribute: g_file_info_get_attribute_data (GFileInfo *info,
* @info: a #GFileInfo. const char *attribute,
* @attribute: a file attribute key. GFileAttributeType *type,
* gpointer *value_pp,
* Gets an attribute value from a file info structure. GFileAttributeStatus *status)
* {
* Returns: a #GFileAttributeValue for the given @attribute, or GFileAttributeValue *value;
* %NULL otherwise.
**/ 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 * GFileAttributeValue *
g_file_info_get_attribute (GFileInfo *info, _g_file_info_get_attribute_value (GFileInfo *info,
const char *attribute) const char *attribute)
{ {
@ -579,6 +613,30 @@ g_file_info_get_attribute (GFileInfo *info,
return g_file_info_find_value_by_name (info, attribute); return g_file_info_find_value_by_name (info, attribute);
} }
/**
* 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: * g_file_info_get_attribute_object:
* @info: a #GFileInfo. * @info: a #GFileInfo.
@ -600,7 +658,7 @@ g_file_info_get_attribute_object (GFileInfo *info,
g_return_val_if_fail (attribute != NULL && *attribute != '\0', NULL); g_return_val_if_fail (attribute != NULL && *attribute != '\0', NULL);
value = g_file_info_find_value_by_name (info, attribute); 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); g_return_val_if_fail (attribute != NULL && *attribute != '\0', NULL);
value = g_file_info_find_value_by_name (info, attribute); 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); g_return_val_if_fail (attribute != NULL && *attribute != '\0', NULL);
value = g_file_info_find_value_by_name (info, attribute); 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); g_return_val_if_fail (attribute != NULL && *attribute != '\0', FALSE);
value = g_file_info_find_value_by_name (info, attribute); 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); g_return_val_if_fail (attribute != NULL && *attribute != '\0', 0);
value = g_file_info_find_value_by_name (info, attribute); 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); g_return_val_if_fail (attribute != NULL && *attribute != '\0', 0);
value = g_file_info_find_value_by_name (info, attribute); 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); g_return_val_if_fail (attribute != NULL && *attribute != '\0', 0);
value = g_file_info_find_value_by_name (info, attribute); 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); g_return_val_if_fail (attribute != NULL && *attribute != '\0', 0);
value = g_file_info_find_value_by_name (info, attribute); 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 * static GFileAttributeValue *
@ -775,7 +833,6 @@ g_file_info_create_value (GFileInfo *info,
guint32 attr_id) guint32 attr_id)
{ {
GFileAttribute *attrs; GFileAttribute *attrs;
GFileAttribute attr;
int i; int i;
if (info->mask != NO_ATTRIBUTE_MASK && if (info->mask != NO_ATTRIBUTE_MASK &&
@ -790,8 +847,8 @@ g_file_info_create_value (GFileInfo *info,
return &attrs[i].value; return &attrs[i].value;
else else
{ {
GFileAttribute attr = { 0 };
attr.attribute = attr_id; attr.attribute = attr_id;
attr.value.type = G_FILE_ATTRIBUTE_TYPE_INVALID;
g_array_insert_val (info->attributes, i, attr); g_array_insert_val (info->attributes, i, attr);
attrs = (GFileAttribute *)info->attributes->data; attrs = (GFileAttribute *)info->attributes->data;
@ -822,17 +879,18 @@ g_file_info_create_value_by_name (GFileInfo *info,
void void
g_file_info_set_attribute (GFileInfo *info, g_file_info_set_attribute (GFileInfo *info,
const char *attribute, const char *attribute,
const GFileAttributeValue *attr_value) GFileAttributeType type,
gpointer value_p)
{ {
GFileAttributeValue *value; GFileAttributeValue *value;
g_return_if_fail (G_IS_FILE_INFO (info)); g_return_if_fail (G_IS_FILE_INFO (info));
g_return_if_fail (attribute != NULL && *attribute != '\0'); 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); value = g_file_info_create_value_by_name (info, attribute);
if (value) 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); value = g_file_info_create_value_by_name (info, attribute);
if (value) 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); value = g_file_info_create_value_by_name (info, attribute);
if (value) 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); value = g_file_info_create_value_by_name (info, attribute);
if (value) 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); value = g_file_info_create_value_by_name (info, attribute);
if (value) 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); value = g_file_info_create_value_by_name (info, attribute);
if (value) 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); value = g_file_info_create_value_by_name (info, attribute);
if (value) 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); value = g_file_info_create_value_by_name (info, attribute);
if (value) 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); value = g_file_info_create_value_by_name (info, attribute);
if (value) if (value)
g_file_attribute_value_set_int64 (value, attr_value); _g_file_attribute_value_set_int64 (value, attr_value);
} }
/* Helper getters */ /* Helper getters */
@ -1054,7 +1112,7 @@ g_file_info_get_file_type (GFileInfo *info)
attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_TYPE); attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_TYPE);
value = g_file_info_find_value (info, attr); 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); attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_IS_HIDDEN);
value = g_file_info_find_value (info, attr); 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); attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_IS_BACKUP);
value = g_file_info_find_value (info, attr); 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); attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_IS_SYMLINK);
value = g_file_info_find_value (info, attr); 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); attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_NAME);
value = g_file_info_find_value (info, attr); 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); attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_DISPLAY_NAME);
value = g_file_info_find_value (info, attr); 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); attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_EDIT_NAME);
value = g_file_info_find_value (info, attr); 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); attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_ICON);
value = g_file_info_find_value (info, attr); 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)) if (obj != NULL && G_IS_ICON (obj))
return G_ICON (obj); return G_ICON (obj);
return NULL; return NULL;
@ -1242,7 +1300,7 @@ g_file_info_get_content_type (GFileInfo *info)
attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_CONTENT_TYPE); attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_CONTENT_TYPE);
value = g_file_info_find_value (info, attr); 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); attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_SIZE);
value = g_file_info_find_value (info, attr); 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); 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); 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); attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_SYMLINK_TARGET);
value = g_file_info_find_value (info, attr); 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); attr = lookup_attribute (G_FILE_ATTRIBUTE_ETAG_VALUE);
value = g_file_info_find_value (info, attr); 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); attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_SORT_ORDER);
value = g_file_info_find_value (info, attr); 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: */ /* Helper setters: */
@ -1392,7 +1450,7 @@ g_file_info_set_file_type (GFileInfo *info,
value = g_file_info_create_value (info, attr); value = g_file_info_create_value (info, attr);
if (value) 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); value = g_file_info_create_value (info, attr);
if (value) 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); value = g_file_info_create_value (info, attr);
if (value) 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); value = g_file_info_create_value (info, attr);
if (value) 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); value = g_file_info_create_value (info, attr);
if (value) 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); value = g_file_info_create_value (info, attr);
if (value) 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); value = g_file_info_create_value (info, attr);
if (value) 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); value = g_file_info_create_value (info, attr);
if (value) 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); value = g_file_info_create_value (info, attr);
if (value) 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); value = g_file_info_create_value (info, attr_mtime);
if (value) 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); value = g_file_info_create_value (info, attr_mtime_usec);
if (value) 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); value = g_file_info_create_value (info, attr);
if (value) 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); value = g_file_info_create_value (info, attr);
if (value) if (value)
g_file_attribute_value_set_int32 (value, sort_order); _g_file_attribute_value_set_int32 (value, sort_order);
} }

View File

@ -683,11 +683,18 @@ gboolean g_file_info_has_attribute (GFileInfo *info,
const char *attribute); const char *attribute);
char ** g_file_info_list_attributes (GFileInfo *info, char ** g_file_info_list_attributes (GFileInfo *info,
const char *name_space); 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, GFileAttributeType g_file_info_get_attribute_type (GFileInfo *info,
const char *attribute); const char *attribute);
void g_file_info_remove_attribute (GFileInfo *info, void g_file_info_remove_attribute (GFileInfo *info,
const char *attribute); 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 *attribute);
const char * g_file_info_get_attribute_string (GFileInfo *info, const char * g_file_info_get_attribute_string (GFileInfo *info,
const char *attribute); const char *attribute);
@ -708,7 +715,8 @@ GObject * g_file_info_get_attribute_object (GFileInfo *info,
void g_file_info_set_attribute (GFileInfo *info, void g_file_info_set_attribute (GFileInfo *info,
const char *attribute, const char *attribute,
const GFileAttributeValue *attr_value); GFileAttributeType type,
gpointer value_p);
void g_file_info_set_attribute_string (GFileInfo *info, void g_file_info_set_attribute_string (GFileInfo *info,
const char *attribute, const char *attribute,
const char *attr_value); const char *attr_value);

View File

@ -65,6 +65,7 @@ g_app_info_get_default_for_uri_scheme
#if IN_FILE(__G_DESKTOP_APP_INFO_C__) #if IN_FILE(__G_DESKTOP_APP_INFO_C__)
g_desktop_app_info_new_from_filename g_desktop_app_info_new_from_filename
g_desktop_app_info_new g_desktop_app_info_new
g_desktop_app_info_get_type G_GNUC_CONST
g_desktop_app_info_get_is_hidden g_desktop_app_info_get_is_hidden
#endif #endif
#endif #endif
@ -204,28 +205,6 @@ g_drive_poll_for_media_finish
#if IN_HEADER(__G_FILE_ATTRIBUTE_H__) #if IN_HEADER(__G_FILE_ATTRIBUTE_H__)
#if IN_FILE(__G_FILE_ATTRIBUTE_C__) #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_new
g_file_attribute_info_list_ref g_file_attribute_info_list_ref
g_file_attribute_info_list_unref g_file_attribute_info_list_unref
@ -354,7 +333,9 @@ g_file_info_has_attribute
g_file_info_list_attributes g_file_info_list_attributes
g_file_info_get_attribute_type g_file_info_get_attribute_type
g_file_info_remove_attribute 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_string
g_file_info_get_attribute_byte_string g_file_info_get_attribute_byte_string
g_file_info_get_attribute_boolean g_file_info_get_attribute_boolean

View File

@ -1020,7 +1020,8 @@ g_local_file_query_writable_namespaces (GFile *file,
static gboolean static gboolean
g_local_file_set_attribute (GFile *file, g_local_file_set_attribute (GFile *file,
const char *attribute, const char *attribute,
const GFileAttributeValue *value, GFileAttributeType type,
gpointer value_p,
GFileQueryInfoFlags flags, GFileQueryInfoFlags flags,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
@ -1029,7 +1030,8 @@ g_local_file_set_attribute (GFile *file,
return _g_local_file_info_set_attribute (local->filename, return _g_local_file_info_set_attribute (local->filename,
attribute, attribute,
value, type,
value_p,
flags, flags,
cancellable, cancellable,
error); error);

View File

@ -57,6 +57,7 @@
#include <glib/gstdio.h> #include <glib/gstdio.h>
#include <glib/gchecksum.h> #include <glib/gchecksum.h>
#include <gfileattribute-priv.h>
#include "glibintl.h" #include "glibintl.h"
@ -1939,42 +1940,47 @@ set_mtime_atime (char *filename,
gboolean gboolean
_g_local_file_info_set_attribute (char *filename, _g_local_file_info_set_attribute (char *filename,
const char *attribute, const char *attribute,
const GFileAttributeValue *value, GFileAttributeType type,
gpointer value_p,
GFileQueryInfoFlags flags, GFileQueryInfoFlags flags,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) 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) 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 #ifdef HAVE_CHOWN
else if (strcmp (attribute, G_FILE_ATTRIBUTE_UNIX_UID) == 0) 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) 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 #endif
#ifdef HAVE_SYMLINK #ifdef HAVE_SYMLINK
else if (strcmp (attribute, G_FILE_ATTRIBUTE_STD_SYMLINK_TARGET) == 0) else if (strcmp (attribute, G_FILE_ATTRIBUTE_STD_SYMLINK_TARGET) == 0)
return set_symlink (filename, value, error); return set_symlink (filename, &value, error);
#endif #endif
#ifdef HAVE_UTIMES #ifdef HAVE_UTIMES
else if (strcmp (attribute, G_FILE_ATTRIBUTE_TIME_MODIFIED) == 0) 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) 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) 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) 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 #endif
#ifdef HAVE_XATTR #ifdef HAVE_XATTR
else if (g_str_has_prefix (attribute, "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::")) else if (g_str_has_prefix (attribute, "xattr-sys::"))
return set_xattr (filename, attribute, value, error); return set_xattr (filename, attribute, &value, error);
#endif #endif
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, 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 */ /* Set symlink first, since this recreates the file */
#ifdef HAVE_SYMLINK #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 (value)
{ {
if (!set_symlink (filename, value, error)) 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 ownership before permissions, since ownership changes can
change permissions (e.g. setuid) change permissions (e.g. setuid)
*/ */
uid = g_file_info_get_attribute (info, G_FILE_ATTRIBUTE_UNIX_UID); uid = _g_file_info_get_attribute_value (info, G_FILE_ATTRIBUTE_UNIX_UID);
gid = g_file_info_get_attribute (info, G_FILE_ATTRIBUTE_UNIX_GID); gid = _g_file_info_get_attribute_value (info, G_FILE_ATTRIBUTE_UNIX_GID);
if (uid || gid) if (uid || gid)
{ {
@ -2043,7 +2049,7 @@ _g_local_file_info_set_attributes (char *filename,
} }
#endif #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 (value)
{ {
if (!set_unix_mode (filename, value, error)) 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 * 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 = _g_file_info_get_attribute_value (info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
mtime_usec = g_file_info_get_attribute (info, G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC); mtime_usec = _g_file_info_get_attribute_value (info, G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC);
atime = g_file_info_get_attribute (info, G_FILE_ATTRIBUTE_TIME_ACCESS); atime = _g_file_info_get_attribute_value (info, G_FILE_ATTRIBUTE_TIME_ACCESS);
atime_usec = g_file_info_get_attribute (info, G_FILE_ATTRIBUTE_TIME_ACCESS_USEC); atime_usec = _g_file_info_get_attribute_value (info, G_FILE_ATTRIBUTE_TIME_ACCESS_USEC);
if (mtime || mtime_usec || atime || atime_usec) if (mtime || mtime_usec || atime || atime_usec)
{ {

View File

@ -54,7 +54,8 @@ GFileInfo *_g_local_file_info_get_from_fd (int fd,
char * _g_local_file_info_create_etag (struct stat *statbuf); char * _g_local_file_info_create_etag (struct stat *statbuf);
gboolean _g_local_file_info_set_attribute (char *filename, gboolean _g_local_file_info_set_attribute (char *filename,
const char *attribute, const char *attribute,
const GFileAttributeValue *value, GFileAttributeType type,
gpointer value_p,
GFileQueryInfoFlags flags, GFileQueryInfoFlags flags,
GCancellable *cancellable, GCancellable *cancellable,
GError **error); GError **error);

View File

@ -63,7 +63,7 @@ static const char *_resolve_dev_root (void);
* *
**/ **/
/** /*
* GUnixMountType: * GUnixMountType:
* @G_UNIX_MOUNT_TYPE_UNKNOWN: Unknown UNIX mount type. * @G_UNIX_MOUNT_TYPE_UNKNOWN: Unknown UNIX mount type.
* @G_UNIX_MOUNT_TYPE_FLOPPY: Floppy disk 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; return type;
} }
/** /*
* g_unix_mount_guess_type: * g_unix_mount_guess_type:
* @mount_entry: a #GUnixMount. * @mount_entry: a #GUnixMount.
* *
@ -1631,7 +1631,7 @@ guess_mount_type (const char *mount_path,
* *
* Returns: a #GUnixMountType. * Returns: a #GUnixMountType.
**/ **/
GUnixMountType static GUnixMountType
g_unix_mount_guess_type (GUnixMountEntry *mount_entry) g_unix_mount_guess_type (GUnixMountEntry *mount_entry)
{ {
g_return_val_if_fail (mount_entry != NULL, G_UNIX_MOUNT_TYPE_UNKNOWN); 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); mount_entry->filesystem_type);
} }
/** /*
* g_unix_mount_point_guess_type: * g_unix_mount_point_guess_type:
* @mount_point: a #GUnixMountPoint. * @mount_point: a #GUnixMountPoint.
* *
@ -1653,7 +1653,7 @@ g_unix_mount_guess_type (GUnixMountEntry *mount_entry)
* *
* Returns: a #GUnixMountType. * Returns: a #GUnixMountType.
**/ **/
GUnixMountType static GUnixMountType
g_unix_mount_point_guess_type (GUnixMountPoint *mount_point) g_unix_mount_point_guess_type (GUnixMountPoint *mount_point)
{ {
g_return_val_if_fail (mount_point != NULL, G_UNIX_MOUNT_TYPE_UNKNOWN); g_return_val_if_fail (mount_point != NULL, G_UNIX_MOUNT_TYPE_UNKNOWN);