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_STRINGV: if (dup) value->u.stringv = g_strdupv (value_p); else value->u.stringv = 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; case G_FILE_ATTRIBUTE_TYPE_INVALID: break; default: g_warning ("Unknown type specified in g_file_info_set_attribute\n"); break; } }
/* * _g_file_attribute_value_free: * @attr: a #GFileAttributeValue. * * Frees the memory used by @attr. * **/ void _g_file_attribute_value_free (GFileAttributeValue *attr) { g_return_if_fail (attr != NULL); _g_file_attribute_value_clear (attr); g_free (attr); }
/* * _g_file_attribute_value_set_int64: * @attr: a #GFileAttributeValue. * @value: a #gint64 to set within the type. * * Sets the attribute value to a given signed 64-bit integer. */ void _g_file_attribute_value_set_int64 (GFileAttributeValue *attr, gint64 value) { g_return_if_fail (attr != NULL); _g_file_attribute_value_clear (attr); attr->type = G_FILE_ATTRIBUTE_TYPE_INT64; attr->u.int64 = value; }
/* * _g_file_attribute_value_set_uint32: * @attr: a #GFileAttributeValue. * @value: a #guint32 to set within the type. * * Sets the attribute value to the given unsigned 32-bit integer. */ void _g_file_attribute_value_set_uint32 (GFileAttributeValue *attr, guint32 value) { g_return_if_fail (attr != NULL); _g_file_attribute_value_clear (attr); attr->type = G_FILE_ATTRIBUTE_TYPE_UINT32; attr->u.uint32 = value; }
/* * _g_file_attribute_value_set_boolean: * @attr: a #GFileAttributeValue. * @value: a #gboolean to set within the type. * * Sets the attribute value to the given boolean value. */ void _g_file_attribute_value_set_boolean (GFileAttributeValue *attr, gboolean value) { g_return_if_fail (attr != NULL); _g_file_attribute_value_clear (attr); attr->type = G_FILE_ATTRIBUTE_TYPE_BOOLEAN; attr->u.boolean = !!value; }
/* * _g_file_attribute_value_set_object: * @attr: a #GFileAttributeValue. * @obj: a #GObject. * * Sets the attribute to contain the value @obj. * The @attr references the GObject internally. */ void _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); attr->type = G_FILE_ATTRIBUTE_TYPE_OBJECT; attr->u.obj = g_object_ref (obj); }
void _g_file_attribute_value_set_stringv (GFileAttributeValue *attr, char **value) { g_return_if_fail (attr != NULL); g_return_if_fail (value != NULL); _g_file_attribute_value_clear (attr); attr->type = G_FILE_ATTRIBUTE_TYPE_STRINGV; attr->u.stringv = g_strdupv (value); }
/* * _g_file_attribute_value_set_byte_string: * @attr: a #GFileAttributeValue. * @string: a byte string to set within the type. * * Sets the attribute value to a given byte string. */ void _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); attr->type = G_FILE_ATTRIBUTE_TYPE_BYTE_STRING; attr->u.string = g_strdup (string); }
/* * g_file_attribute_value_set: * @attr: a #GFileAttributeValue to set the value in. * @new_value: a #GFileAttributeValue to get the value from. * * Sets an attribute's value from another attribute. **/ void _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); *attr = *new_value; if (attr->type == G_FILE_ATTRIBUTE_TYPE_STRING || attr->type == G_FILE_ATTRIBUTE_TYPE_BYTE_STRING) attr->u.string = g_strdup (attr->u.string); if (attr->type == G_FILE_ATTRIBUTE_TYPE_OBJECT && attr->u.obj != NULL) g_object_ref (attr->u.obj); }