Blame gio/gfileattribute.c

Packit ae235b
/* GIO - GLib Input, Output and Streaming Library
Packit ae235b
 *
Packit ae235b
 * Copyright (C) 2006-2007 Red Hat, Inc.
Packit ae235b
 *
Packit ae235b
 * This library is free software; you can redistribute it and/or
Packit ae235b
 * modify it under the terms of the GNU Lesser General Public
Packit ae235b
 * License as published by the Free Software Foundation; either
Packit ae235b
 * version 2.1 of the License, or (at your option) any later version.
Packit ae235b
 *
Packit ae235b
 * This library is distributed in the hope that it will be useful,
Packit ae235b
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit ae235b
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit ae235b
 * Lesser General Public License for more details.
Packit ae235b
 *
Packit ae235b
 * You should have received a copy of the GNU Lesser General
Packit ae235b
 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
Packit ae235b
 *
Packit ae235b
 * Author: Alexander Larsson <alexl@redhat.com>
Packit ae235b
 */
Packit ae235b
Packit ae235b
#include "config.h"
Packit ae235b
Packit ae235b
#include <string.h>
Packit ae235b
Packit ae235b
#include "gfileattribute.h"
Packit ae235b
#include "gfileattribute-priv.h"
Packit ae235b
#include <glib-object.h>
Packit ae235b
#include "glibintl.h"
Packit ae235b
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * SECTION:gfileattribute
Packit ae235b
 * @short_description: Key-Value Paired File Attributes
Packit ae235b
 * @include: gio/gio.h
Packit ae235b
 * @see_also: #GFile, #GFileInfo
Packit ae235b
 *
Packit ae235b
 * File attributes in GIO consist of a list of key-value pairs.
Packit ae235b
 *
Packit ae235b
 * Keys are strings that contain a key namespace and a key name, separated
Packit ae235b
 * by a colon, e.g. "namespace::keyname". Namespaces are included to sort
Packit ae235b
 * key-value pairs by namespaces for relevance. Keys can be retrived
Packit ae235b
 * using wildcards, e.g. "standard::*" will return all of the keys in the
Packit ae235b
 * "standard" namespace.
Packit ae235b
 *
Packit ae235b
 * The list of possible attributes for a filesystem (pointed to by a #GFile) is
Packit ae235b
 * available as a #GFileAttributeInfoList. This list is queryable by key names
Packit ae235b
 * as indicated earlier.
Packit ae235b
 *
Packit ae235b
 * Information is stored within the list in #GFileAttributeInfo structures.
Packit ae235b
 * The info structure can store different types, listed in the enum
Packit ae235b
 * #GFileAttributeType. Upon creation of a #GFileAttributeInfo, the type will
Packit ae235b
 * be set to %G_FILE_ATTRIBUTE_TYPE_INVALID.
Packit ae235b
 *
Packit ae235b
 * Classes that implement #GFileIface will create a #GFileAttributeInfoList and
Packit ae235b
 * install default keys and values for their given file system, architecture,
Packit ae235b
 * and other possible implementation details (e.g., on a UNIX system, a file
Packit ae235b
 * attribute key will be registered for the user id for a given file).
Packit ae235b
 *
Packit ae235b
 * ## Default Namespaces
Packit ae235b
 *
Packit ae235b
 * - `"standard"`: The "Standard" namespace. General file information that
Packit ae235b
 *   any application may need should be put in this namespace. Examples
Packit ae235b
 *   include the file's name, type, and size.
Packit ae235b
 * - `"etag`: The [Entity Tag][gfile-etag] namespace. Currently, the only key
Packit ae235b
 *   in this namespace is "value", which contains the value of the current
Packit ae235b
 *   entity tag.
Packit ae235b
 * - `"id"`: The "Identification" namespace. This namespace is used by file
Packit ae235b
 *   managers and applications that list directories to check for loops and
Packit ae235b
 *   to uniquely identify files.
Packit ae235b
 * - `"access"`: The "Access" namespace. Used to check if a user has the
Packit ae235b
 *   proper privileges to access files and perform file operations. Keys in
Packit ae235b
 *   this namespace are made to be generic and easily understood, e.g. the
Packit ae235b
 *   "can_read" key is %TRUE if the current user has permission to read the
Packit ae235b
 *   file. UNIX permissions and NTFS ACLs in Windows should be mapped to
Packit ae235b
 *   these values.
Packit ae235b
 * - `"mountable"`: The "Mountable" namespace. Includes simple boolean keys
Packit ae235b
 *   for checking if a file or path supports mount operations, e.g. mount,
Packit ae235b
 *   unmount, eject. These are used for files of type %G_FILE_TYPE_MOUNTABLE.
Packit ae235b
 * - `"time"`: The "Time" namespace. Includes file access, changed, created
Packit ae235b
 *   times.
Packit ae235b
 * - `"unix"`: The "Unix" namespace. Includes UNIX-specific information and
Packit ae235b
 *   may not be available for all files. Examples include the UNIX "UID",
Packit ae235b
 *   "GID", etc.
Packit ae235b
 * - `"dos"`: The "DOS" namespace. Includes DOS-specific information and may
Packit ae235b
 *   not be available for all files. Examples include "is_system" for checking
Packit ae235b
 *   if a file is marked as a system file, and "is_archive" for checking if a
Packit ae235b
 *   file is marked as an archive file.
Packit ae235b
 * - `"owner"`: The "Owner" namespace. Includes information about who owns a
Packit ae235b
 *   file. May not be available for all file systems. Examples include "user"
Packit ae235b
 *   for getting the user name of the file owner. This information is often
Packit ae235b
 *   mapped from some backend specific data such as a UNIX UID.
Packit ae235b
 * - `"thumbnail"`: The "Thumbnail" namespace. Includes information about file
Packit ae235b
 *   thumbnails and their location within the file system. Examples of keys in
Packit ae235b
 *   this namespace include "path" to get the location of a thumbnail, "failed"
Packit ae235b
 *   to check if thumbnailing of the file failed, and "is-valid" to check if
Packit ae235b
 *   the thumbnail is outdated.
Packit ae235b
 * - `"filesystem"`: The "Filesystem" namespace. Gets information about the
Packit ae235b
 *   file system where a file is located, such as its type, how much space is
Packit ae235b
 *   left available, and the overall size of the file system.
Packit ae235b
 * - `"gvfs"`: The "GVFS" namespace. Keys in this namespace contain information
Packit ae235b
 *   about the current GVFS backend in use.
Packit ae235b
 * - `"xattr"`: The "xattr" namespace. Gets information about extended
Packit ae235b
 *   user attributes. See attr(5). The "user." prefix of the extended user
Packit ae235b
 *   attribute name is stripped away when constructing keys in this namespace,
Packit ae235b
 *   e.g. "xattr::mime_type" for the extended attribute with the name
Packit ae235b
 *   "user.mime_type". Note that this information is only available if
Packit ae235b
 *   GLib has been built with extended attribute support.
Packit ae235b
 * - `"xattr-sys"`: The "xattr-sys" namespace. Gets information about
Packit ae235b
 *   extended attributes which are not user-specific. See attr(5). Note
Packit ae235b
 *   that this information is only available if GLib has been built with
Packit ae235b
 *   extended attribute support.
Packit ae235b
 * - `"selinux"`: The "SELinux" namespace. Includes information about the
Packit ae235b
 *   SELinux context of files. Note that this information is only available
Packit ae235b
 *   if GLib has been built with SELinux support.
Packit ae235b
 *
Packit ae235b
 * Please note that these are not all of the possible namespaces.
Packit ae235b
 * More namespaces can be added from GIO modules or by individual applications.
Packit ae235b
 * For more information about writing GIO modules, see #GIOModule.
Packit ae235b
 *
Packit ae235b
 * 
Packit ae235b
 * file systems -->
Packit ae235b
 *
Packit ae235b
 * ## Default Keys
Packit ae235b
 *
Packit ae235b
 * For a list of the built-in keys and their types, see the
Packit ae235b
 * [GFileInfo][GFileInfo] documentation.
Packit ae235b
 *
Packit ae235b
 * Note that there are no predefined keys in the "xattr" and "xattr-sys"
Packit ae235b
 * namespaces. Keys for the "xattr" namespace are constructed by stripping
Packit ae235b
 * away the "user." prefix from the extended user attribute, and prepending
Packit ae235b
 * "xattr::". Keys for the "xattr-sys" namespace are constructed by
Packit ae235b
 * concatenating "xattr-sys::" with the extended attribute name. All extended
Packit ae235b
 * attribute values are returned as hex-encoded strings in which bytes outside
Packit ae235b
 * the ASCII range are encoded as escape sequences of the form \x`nn`
Packit ae235b
 * where `nn` is a 2-digit hexadecimal number.
Packit ae235b
 */
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * _g_file_attribute_value_free:
Packit ae235b
 * @attr: a #GFileAttributeValue.
Packit ae235b
 *
Packit ae235b
 * Frees the memory used by @attr.
Packit ae235b
 *
Packit ae235b
 **/
Packit ae235b
void
Packit ae235b
_g_file_attribute_value_free (GFileAttributeValue *attr)
Packit ae235b
{
Packit ae235b
  g_return_if_fail (attr != NULL);
Packit ae235b
Packit ae235b
  _g_file_attribute_value_clear (attr);
Packit ae235b
  g_free (attr);
Packit ae235b
}
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * _g_file_attribute_value_clear:
Packit ae235b
 * @attr: a #GFileAttributeValue.
Packit ae235b
 *
Packit ae235b
 * Clears the value of @attr and sets its type to
Packit ae235b
 * %G_FILE_ATTRIBUTE_TYPE_INVALID.
Packit ae235b
 *
Packit ae235b
 **/
Packit ae235b
void
Packit ae235b
_g_file_attribute_value_clear (GFileAttributeValue *attr)
Packit ae235b
{
Packit ae235b
  g_return_if_fail (attr != NULL);
Packit ae235b
Packit ae235b
  if (attr->type == G_FILE_ATTRIBUTE_TYPE_STRING ||
Packit ae235b
      attr->type == G_FILE_ATTRIBUTE_TYPE_BYTE_STRING)
Packit ae235b
    g_free (attr->u.string);
Packit ae235b
Packit ae235b
  if (attr->type == G_FILE_ATTRIBUTE_TYPE_STRINGV)
Packit ae235b
    g_strfreev (attr->u.stringv);
Packit ae235b
Packit ae235b
  if (attr->type == G_FILE_ATTRIBUTE_TYPE_OBJECT &&
Packit ae235b
      attr->u.obj != NULL)
Packit ae235b
    g_object_unref (attr->u.obj);
Packit ae235b
Packit ae235b
  attr->type = G_FILE_ATTRIBUTE_TYPE_INVALID;
Packit ae235b
}
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * g_file_attribute_value_set:
Packit ae235b
 * @attr: a #GFileAttributeValue to set the value in.
Packit ae235b
 * @new_value: a #GFileAttributeValue to get the value from.
Packit ae235b
 *
Packit ae235b
 * Sets an attribute's value from another attribute.
Packit ae235b
 **/
Packit ae235b
void
Packit ae235b
_g_file_attribute_value_set (GFileAttributeValue        *attr,
Packit ae235b
			     const GFileAttributeValue *new_value)
Packit ae235b
{
Packit ae235b
  g_return_if_fail (attr != NULL);
Packit ae235b
  g_return_if_fail (new_value != NULL);
Packit ae235b
Packit ae235b
  _g_file_attribute_value_clear (attr);
Packit ae235b
  *attr = *new_value;
Packit ae235b
Packit ae235b
  if (attr->type == G_FILE_ATTRIBUTE_TYPE_STRING ||
Packit ae235b
      attr->type == G_FILE_ATTRIBUTE_TYPE_BYTE_STRING)
Packit ae235b
    attr->u.string = g_strdup (attr->u.string);
Packit ae235b
Packit ae235b
  if (attr->type == G_FILE_ATTRIBUTE_TYPE_STRINGV)
Packit ae235b
    attr->u.stringv = g_strdupv (attr->u.stringv);
Packit ae235b
Packit ae235b
  if (attr->type == G_FILE_ATTRIBUTE_TYPE_OBJECT &&
Packit ae235b
      attr->u.obj != NULL)
Packit ae235b
    g_object_ref (attr->u.obj);
Packit ae235b
}
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * _g_file_attribute_value_new:
Packit ae235b
 *
Packit ae235b
 * Creates a new file attribute.
Packit ae235b
 *
Packit ae235b
 * Returns: a #GFileAttributeValue.
Packit ae235b
 **/
Packit ae235b
GFileAttributeValue *
Packit ae235b
_g_file_attribute_value_new (void)
Packit ae235b
{
Packit ae235b
  GFileAttributeValue *attr;
Packit ae235b
Packit ae235b
  attr = g_new (GFileAttributeValue, 1);
Packit ae235b
  attr->type = G_FILE_ATTRIBUTE_TYPE_INVALID;
Packit ae235b
  return attr;
Packit ae235b
}
Packit ae235b
Packit ae235b
gpointer
Packit ae235b
_g_file_attribute_value_peek_as_pointer (GFileAttributeValue *attr)
Packit ae235b
{
Packit ae235b
  switch (attr->type) {
Packit ae235b
  case G_FILE_ATTRIBUTE_TYPE_STRING:
Packit ae235b
  case G_FILE_ATTRIBUTE_TYPE_BYTE_STRING:
Packit ae235b
    return attr->u.string;
Packit ae235b
  case G_FILE_ATTRIBUTE_TYPE_STRINGV:
Packit ae235b
    return attr->u.stringv;
Packit ae235b
  case G_FILE_ATTRIBUTE_TYPE_OBJECT:
Packit ae235b
    return attr->u.obj;
Packit ae235b
  default:
Packit ae235b
    return (gpointer) &attr->u;
Packit ae235b
  }
Packit ae235b
}
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * g_file_attribute_value_dup:
Packit ae235b
 * @other: a #GFileAttributeValue to duplicate.
Packit ae235b
 *
Packit ae235b
 * Duplicates a file attribute.
Packit ae235b
 *
Packit ae235b
 * Returns: a duplicate of the @other.
Packit ae235b
 **/
Packit ae235b
GFileAttributeValue *
Packit ae235b
_g_file_attribute_value_dup (const GFileAttributeValue *other)
Packit ae235b
{
Packit ae235b
  GFileAttributeValue *attr;
Packit ae235b
Packit ae235b
  g_return_val_if_fail (other != NULL, NULL);
Packit ae235b
Packit ae235b
  attr = g_new (GFileAttributeValue, 1);
Packit ae235b
  attr->type = G_FILE_ATTRIBUTE_TYPE_INVALID;
Packit ae235b
  _g_file_attribute_value_set (attr, other);
Packit ae235b
  return attr;
Packit ae235b
}
Packit ae235b
Packit ae235b
G_DEFINE_BOXED_TYPE (GFileAttributeInfoList, g_file_attribute_info_list,
Packit ae235b
                     g_file_attribute_info_list_dup,
Packit ae235b
                     g_file_attribute_info_list_unref)
Packit ae235b
Packit ae235b
static gboolean
Packit ae235b
valid_char (char c)
Packit ae235b
{
Packit ae235b
  return c >= 32 && c <= 126 && c != '\\';
Packit ae235b
}
Packit ae235b
Packit ae235b
static char *
Packit ae235b
escape_byte_string (const char *str)
Packit ae235b
{
Packit ae235b
  size_t len;
Packit ae235b
  int num_invalid, i;
Packit ae235b
  char *escaped_val, *p;
Packit ae235b
  unsigned char c;
Packit ae235b
  const char hex_digits[] = "0123456789abcdef";
Packit ae235b
Packit ae235b
  len = strlen (str);
Packit ae235b
Packit ae235b
  num_invalid = 0;
Packit ae235b
  for (i = 0; i < len; i++)
Packit ae235b
    {
Packit ae235b
      if (!valid_char (str[i]))
Packit ae235b
	num_invalid++;
Packit ae235b
    }
Packit ae235b
Packit ae235b
  if (num_invalid == 0)
Packit ae235b
    return g_strdup (str);
Packit ae235b
  else
Packit ae235b
    {
Packit ae235b
      escaped_val = g_malloc (len + num_invalid*3 + 1);
Packit ae235b
Packit ae235b
      p = escaped_val;
Packit ae235b
      for (i = 0; i < len; i++)
Packit ae235b
	{
Packit ae235b
	  c = str[i];
Packit ae235b
	  if (valid_char (c))
Packit ae235b
	    *p++ = c;
Packit ae235b
	  else
Packit ae235b
	    {
Packit ae235b
	      *p++ = '\\';
Packit ae235b
	      *p++ = 'x';
Packit ae235b
	      *p++ = hex_digits[(c >> 4) & 0xf];
Packit ae235b
	      *p++ = hex_digits[c & 0xf];
Packit ae235b
	    }
Packit ae235b
	}
Packit ae235b
      *p++ = 0;
Packit ae235b
      return escaped_val;
Packit ae235b
    }
Packit ae235b
}
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * _g_file_attribute_value_as_string:
Packit ae235b
 * @attr: a #GFileAttributeValue.
Packit ae235b
 *
Packit ae235b
 * Converts a #GFileAttributeValue to a string for display.
Packit ae235b
 * The returned string should be freed when no longer needed.
Packit ae235b
 *
Packit ae235b
 * Returns: a string from the @attr, %NULL on error, or "<invalid>"
Packit ae235b
 * if @attr is of type %G_FILE_ATTRIBUTE_TYPE_INVALID.
Packit ae235b
 */
Packit ae235b
char *
Packit ae235b
_g_file_attribute_value_as_string (const GFileAttributeValue *attr)
Packit ae235b
{
Packit ae235b
  GString *s;
Packit ae235b
  int i;
Packit ae235b
  char *str;
Packit ae235b
Packit ae235b
  g_return_val_if_fail (attr != NULL, NULL);
Packit ae235b
Packit ae235b
  switch (attr->type)
Packit ae235b
    {
Packit ae235b
    case G_FILE_ATTRIBUTE_TYPE_STRING:
Packit ae235b
      str = g_strdup (attr->u.string);
Packit ae235b
      break;
Packit ae235b
    case G_FILE_ATTRIBUTE_TYPE_STRINGV:
Packit ae235b
      s = g_string_new ("[");
Packit ae235b
      for (i = 0; attr->u.stringv[i] != NULL; i++)
Packit ae235b
	{
Packit ae235b
	  g_string_append (s, attr->u.stringv[i]);
Packit ae235b
	  if (attr->u.stringv[i+1] != NULL)
Packit ae235b
	    g_string_append (s, ", ");
Packit ae235b
	}
Packit ae235b
      g_string_append (s, "]");
Packit ae235b
      str = g_string_free (s, FALSE);
Packit ae235b
      break;
Packit ae235b
    case G_FILE_ATTRIBUTE_TYPE_BYTE_STRING:
Packit ae235b
      str = escape_byte_string (attr->u.string);
Packit ae235b
      break;
Packit ae235b
    case G_FILE_ATTRIBUTE_TYPE_BOOLEAN:
Packit ae235b
      str = g_strdup_printf ("%s", attr->u.boolean?"TRUE":"FALSE");
Packit ae235b
      break;
Packit ae235b
    case G_FILE_ATTRIBUTE_TYPE_UINT32:
Packit ae235b
      str = g_strdup_printf ("%u", (unsigned int)attr->u.uint32);
Packit ae235b
      break;
Packit ae235b
    case G_FILE_ATTRIBUTE_TYPE_INT32:
Packit ae235b
      str = g_strdup_printf ("%i", (int)attr->u.int32);
Packit ae235b
      break;
Packit ae235b
    case G_FILE_ATTRIBUTE_TYPE_UINT64:
Packit ae235b
      str = g_strdup_printf ("%"G_GUINT64_FORMAT, attr->u.uint64);
Packit ae235b
      break;
Packit ae235b
    case G_FILE_ATTRIBUTE_TYPE_INT64:
Packit ae235b
      str = g_strdup_printf ("%"G_GINT64_FORMAT, attr->u.int64);
Packit ae235b
      break;
Packit ae235b
    case G_FILE_ATTRIBUTE_TYPE_OBJECT:
Packit ae235b
      str = g_strdup_printf ("%s:%p", g_type_name_from_instance
Packit ae235b
                                          ((GTypeInstance *) attr->u.obj),
Packit ae235b
                                      attr->u.obj);
Packit ae235b
      break;
Packit ae235b
    case G_FILE_ATTRIBUTE_TYPE_INVALID:
Packit ae235b
      str = g_strdup ("<unset>");
Packit ae235b
      break;
Packit ae235b
    default:
Packit ae235b
      g_warning ("Invalid type in GFileInfo attribute");
Packit ae235b
      str = g_strdup ("<invalid>");
Packit ae235b
      break;
Packit ae235b
    }
Packit ae235b
Packit ae235b
  return str;
Packit ae235b
}
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * _g_file_attribute_value_get_string:
Packit ae235b
 * @attr: a #GFileAttributeValue.
Packit ae235b
 *
Packit ae235b
 * Gets the string from a file attribute value. If the value is not the
Packit ae235b
 * right type then %NULL will be returned.
Packit ae235b
 *
Packit ae235b
 * Returns: the UTF-8 string value contained within the attribute, or %NULL.
Packit ae235b
 */
Packit ae235b
const char *
Packit ae235b
_g_file_attribute_value_get_string (const GFileAttributeValue *attr)
Packit ae235b
{
Packit ae235b
  if (attr == NULL)
Packit ae235b
    return NULL;
Packit ae235b
Packit ae235b
  g_return_val_if_fail (attr->type == G_FILE_ATTRIBUTE_TYPE_STRING, NULL);
Packit ae235b
Packit ae235b
  return attr->u.string;
Packit ae235b
}
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * _g_file_attribute_value_get_byte_string:
Packit ae235b
 * @attr: a #GFileAttributeValue.
Packit ae235b
 *
Packit ae235b
 * Gets the byte string from a file attribute value. If the value is not the
Packit ae235b
 * right type then %NULL will be returned.
Packit ae235b
 *
Packit ae235b
 * Returns: the byte string contained within the attribute or %NULL.
Packit ae235b
 */
Packit ae235b
const char *
Packit ae235b
_g_file_attribute_value_get_byte_string (const GFileAttributeValue *attr)
Packit ae235b
{
Packit ae235b
  if (attr == NULL)
Packit ae235b
    return NULL;
Packit ae235b
Packit ae235b
  g_return_val_if_fail (attr->type == G_FILE_ATTRIBUTE_TYPE_BYTE_STRING, NULL);
Packit ae235b
Packit ae235b
  return attr->u.string;
Packit ae235b
}
Packit ae235b
Packit ae235b
char **
Packit ae235b
_g_file_attribute_value_get_stringv (const GFileAttributeValue *attr)
Packit ae235b
{
Packit ae235b
  if (attr == NULL)
Packit ae235b
    return NULL;
Packit ae235b
Packit ae235b
  g_return_val_if_fail (attr->type == G_FILE_ATTRIBUTE_TYPE_STRINGV, NULL);
Packit ae235b
Packit ae235b
  return attr->u.stringv;
Packit ae235b
}
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * _g_file_attribute_value_get_boolean:
Packit ae235b
 * @attr: a #GFileAttributeValue.
Packit ae235b
 *
Packit ae235b
 * Gets the boolean value from a file attribute value. If the value is not the
Packit ae235b
 * right type then %FALSE will be returned.
Packit ae235b
 *
Packit ae235b
 * Returns: the boolean value contained within the attribute, or %FALSE.
Packit ae235b
 */
Packit ae235b
gboolean
Packit ae235b
_g_file_attribute_value_get_boolean (const GFileAttributeValue *attr)
Packit ae235b
{
Packit ae235b
  if (attr == NULL)
Packit ae235b
    return FALSE;
Packit ae235b
Packit ae235b
  g_return_val_if_fail (attr->type == G_FILE_ATTRIBUTE_TYPE_BOOLEAN, FALSE);
Packit ae235b
Packit ae235b
  return attr->u.boolean;
Packit ae235b
}
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * _g_file_attribute_value_get_uint32:
Packit ae235b
 * @attr: a #GFileAttributeValue.
Packit ae235b
 *
Packit ae235b
 * Gets the unsigned 32-bit integer from a file attribute value. If the value
Packit ae235b
 * is not the right type then 0 will be returned.
Packit ae235b
 *
Packit ae235b
 * Returns: the unsigned 32-bit integer from the attribute, or 0.
Packit ae235b
 */
Packit ae235b
guint32
Packit ae235b
_g_file_attribute_value_get_uint32 (const GFileAttributeValue *attr)
Packit ae235b
{
Packit ae235b
  if (attr == NULL)
Packit ae235b
    return 0;
Packit ae235b
Packit ae235b
  g_return_val_if_fail (attr->type == G_FILE_ATTRIBUTE_TYPE_UINT32, 0);
Packit ae235b
Packit ae235b
  return attr->u.uint32;
Packit ae235b
}
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * _g_file_attribute_value_get_int32:
Packit ae235b
 * @attr: a #GFileAttributeValue.
Packit ae235b
 *
Packit ae235b
 * Gets the signed 32-bit integer from a file attribute value. If the value
Packit ae235b
 * is not the right type then 0 will be returned.
Packit ae235b
 *
Packit ae235b
 * Returns: the signed 32-bit integer from the attribute, or 0.
Packit ae235b
 */
Packit ae235b
gint32
Packit ae235b
_g_file_attribute_value_get_int32 (const GFileAttributeValue *attr)
Packit ae235b
{
Packit ae235b
  if (attr == NULL)
Packit ae235b
    return 0;
Packit ae235b
Packit ae235b
  g_return_val_if_fail (attr->type == G_FILE_ATTRIBUTE_TYPE_INT32, 0);
Packit ae235b
Packit ae235b
  return attr->u.int32;
Packit ae235b
}
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * _g_file_attribute_value_get_uint64:
Packit ae235b
 * @attr: a #GFileAttributeValue.
Packit ae235b
 *
Packit ae235b
 * Gets the unsigned 64-bit integer from a file attribute value. If the value
Packit ae235b
 * is not the right type then 0 will be returned.
Packit ae235b
 *
Packit ae235b
 * Returns: the unsigned 64-bit integer from the attribute, or 0.
Packit ae235b
 */
Packit ae235b
guint64
Packit ae235b
_g_file_attribute_value_get_uint64 (const GFileAttributeValue *attr)
Packit ae235b
{
Packit ae235b
  if (attr == NULL)
Packit ae235b
    return 0;
Packit ae235b
Packit ae235b
  g_return_val_if_fail (attr->type == G_FILE_ATTRIBUTE_TYPE_UINT64, 0);
Packit ae235b
Packit ae235b
  return attr->u.uint64;
Packit ae235b
}
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * _g_file_attribute_value_get_int64:
Packit ae235b
 * @attr: a #GFileAttributeValue.
Packit ae235b
 *
Packit ae235b
 * Gets the signed 64-bit integer from a file attribute value. If the value
Packit ae235b
 * is not the right type then 0 will be returned.
Packit ae235b
 *
Packit ae235b
 * Returns: the signed 64-bit integer from the attribute, or 0.
Packit ae235b
 */
Packit ae235b
gint64
Packit ae235b
_g_file_attribute_value_get_int64 (const GFileAttributeValue *attr)
Packit ae235b
{
Packit ae235b
  if (attr == NULL)
Packit ae235b
    return 0;
Packit ae235b
Packit ae235b
  g_return_val_if_fail (attr->type == G_FILE_ATTRIBUTE_TYPE_INT64, 0);
Packit ae235b
Packit ae235b
  return attr->u.int64;
Packit ae235b
}
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * _g_file_attribute_value_get_object:
Packit ae235b
 * @attr: a #GFileAttributeValue.
Packit ae235b
 *
Packit ae235b
 * Gets the GObject from a file attribute value. If the value
Packit ae235b
 * is not the right type then %NULL will be returned.
Packit ae235b
 *
Packit ae235b
 * Returns: the GObject from the attribute, or %NULL.
Packit ae235b
 **/
Packit ae235b
GObject *
Packit ae235b
_g_file_attribute_value_get_object (const GFileAttributeValue *attr)
Packit ae235b
{
Packit ae235b
  if (attr == NULL)
Packit ae235b
    return NULL;
Packit ae235b
Packit ae235b
  g_return_val_if_fail (attr->type == G_FILE_ATTRIBUTE_TYPE_OBJECT, NULL);
Packit ae235b
Packit ae235b
  return attr->u.obj;
Packit ae235b
}
Packit ae235b
Packit ae235b
Packit ae235b
void
Packit ae235b
_g_file_attribute_value_set_from_pointer (GFileAttributeValue *value,
Packit ae235b
					  GFileAttributeType   type,
Packit ae235b
					  gpointer             value_p,
Packit ae235b
					  gboolean             dup)
Packit ae235b
{
Packit ae235b
  _g_file_attribute_value_clear (value);
Packit ae235b
  value->type = type;
Packit ae235b
  switch (type)
Packit ae235b
    {
Packit ae235b
    case G_FILE_ATTRIBUTE_TYPE_STRING:
Packit ae235b
    case G_FILE_ATTRIBUTE_TYPE_BYTE_STRING:
Packit ae235b
      if (dup)
Packit ae235b
	value->u.string = g_strdup (value_p);
Packit ae235b
      else
Packit ae235b
	value->u.string = value_p;
Packit ae235b
      break;
Packit ae235b
Packit ae235b
    case G_FILE_ATTRIBUTE_TYPE_STRINGV:
Packit ae235b
      if (dup)
Packit ae235b
	value->u.stringv = g_strdupv (value_p);
Packit ae235b
      else
Packit ae235b
	value->u.stringv = value_p;
Packit ae235b
      break;
Packit ae235b
Packit ae235b
    case G_FILE_ATTRIBUTE_TYPE_OBJECT:
Packit ae235b
      if (dup)
Packit ae235b
	value->u.obj = g_object_ref (value_p);
Packit ae235b
      else
Packit ae235b
	value->u.obj = value_p;
Packit ae235b
      break;
Packit ae235b
Packit ae235b
    case G_FILE_ATTRIBUTE_TYPE_BOOLEAN:
Packit ae235b
      value->u.boolean = *(gboolean *)value_p;
Packit ae235b
      break;
Packit ae235b
Packit ae235b
    case G_FILE_ATTRIBUTE_TYPE_UINT32:
Packit ae235b
      value->u.uint32 = *(guint32 *)value_p;
Packit ae235b
      break;
Packit ae235b
Packit ae235b
    case G_FILE_ATTRIBUTE_TYPE_INT32:
Packit ae235b
      value->u.int32 = *(gint32 *)value_p;
Packit ae235b
      break;
Packit ae235b
Packit ae235b
    case G_FILE_ATTRIBUTE_TYPE_UINT64:
Packit ae235b
      value->u.uint64 = *(guint64 *)value_p;
Packit ae235b
      break;
Packit ae235b
Packit ae235b
    case G_FILE_ATTRIBUTE_TYPE_INT64:
Packit ae235b
      value->u.int64 = *(gint64 *)value_p;
Packit ae235b
      break;
Packit ae235b
Packit ae235b
    case G_FILE_ATTRIBUTE_TYPE_INVALID:
Packit ae235b
      break;
Packit ae235b
Packit ae235b
    default:
Packit ae235b
      g_warning ("Unknown type specified in g_file_info_set_attribute\n");
Packit ae235b
      break;
Packit ae235b
    }
Packit ae235b
}
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * _g_file_attribute_value_set_string:
Packit ae235b
 * @attr: a #GFileAttributeValue.
Packit ae235b
 * @string: a UTF-8 string to set within the type.
Packit ae235b
 *
Packit ae235b
 * Sets the attribute value to a given UTF-8 string.
Packit ae235b
 */
Packit ae235b
void
Packit ae235b
_g_file_attribute_value_set_string (GFileAttributeValue *attr,
Packit ae235b
				    const char          *string)
Packit ae235b
{
Packit ae235b
  g_return_if_fail (attr != NULL);
Packit ae235b
  g_return_if_fail (string != NULL);
Packit ae235b
Packit ae235b
  _g_file_attribute_value_clear (attr);
Packit ae235b
  attr->type = G_FILE_ATTRIBUTE_TYPE_STRING;
Packit ae235b
  attr->u.string = g_strdup (string);
Packit ae235b
}
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * _g_file_attribute_value_set_byte_string:
Packit ae235b
 * @attr: a #GFileAttributeValue.
Packit ae235b
 * @string: a byte string to set within the type.
Packit ae235b
 *
Packit ae235b
 * Sets the attribute value to a given byte string.
Packit ae235b
 */
Packit ae235b
void
Packit ae235b
_g_file_attribute_value_set_byte_string (GFileAttributeValue *attr,
Packit ae235b
					 const char          *string)
Packit ae235b
{
Packit ae235b
  g_return_if_fail (attr != NULL);
Packit ae235b
  g_return_if_fail (string != NULL);
Packit ae235b
Packit ae235b
  _g_file_attribute_value_clear (attr);
Packit ae235b
  attr->type = G_FILE_ATTRIBUTE_TYPE_BYTE_STRING;
Packit ae235b
  attr->u.string = g_strdup (string);
Packit ae235b
}
Packit ae235b
Packit ae235b
void
Packit ae235b
_g_file_attribute_value_set_stringv (GFileAttributeValue *attr,
Packit ae235b
				     char               **value)
Packit ae235b
{
Packit ae235b
  g_return_if_fail (attr != NULL);
Packit ae235b
  g_return_if_fail (value != NULL);
Packit ae235b
Packit ae235b
  _g_file_attribute_value_clear (attr);
Packit ae235b
  attr->type = G_FILE_ATTRIBUTE_TYPE_STRINGV;
Packit ae235b
  attr->u.stringv = g_strdupv (value);
Packit ae235b
}
Packit ae235b
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * _g_file_attribute_value_set_boolean:
Packit ae235b
 * @attr: a #GFileAttributeValue.
Packit ae235b
 * @value: a #gboolean to set within the type.
Packit ae235b
 *
Packit ae235b
 * Sets the attribute value to the given boolean value.
Packit ae235b
 */
Packit ae235b
void
Packit ae235b
_g_file_attribute_value_set_boolean (GFileAttributeValue *attr,
Packit ae235b
				     gboolean             value)
Packit ae235b
{
Packit ae235b
  g_return_if_fail (attr != NULL);
Packit ae235b
Packit ae235b
  _g_file_attribute_value_clear (attr);
Packit ae235b
  attr->type = G_FILE_ATTRIBUTE_TYPE_BOOLEAN;
Packit ae235b
  attr->u.boolean = !!value;
Packit ae235b
}
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * _g_file_attribute_value_set_uint32:
Packit ae235b
 * @attr: a #GFileAttributeValue.
Packit ae235b
 * @value: a #guint32 to set within the type.
Packit ae235b
 *
Packit ae235b
 * Sets the attribute value to the given unsigned 32-bit integer.
Packit ae235b
 */
Packit ae235b
void
Packit ae235b
_g_file_attribute_value_set_uint32 (GFileAttributeValue *attr,
Packit ae235b
				    guint32              value)
Packit ae235b
{
Packit ae235b
  g_return_if_fail (attr != NULL);
Packit ae235b
Packit ae235b
  _g_file_attribute_value_clear (attr);
Packit ae235b
  attr->type = G_FILE_ATTRIBUTE_TYPE_UINT32;
Packit ae235b
  attr->u.uint32 = value;
Packit ae235b
}
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * _g_file_attribute_value_set_int32:
Packit ae235b
 * @attr: a #GFileAttributeValue.
Packit ae235b
 * @value: a #gint32 to set within the type.
Packit ae235b
 *
Packit ae235b
 * Sets the attribute value to the given signed 32-bit integer.
Packit ae235b
 */
Packit ae235b
void
Packit ae235b
_g_file_attribute_value_set_int32 (GFileAttributeValue *attr,
Packit ae235b
				   gint32               value)
Packit ae235b
{
Packit ae235b
  g_return_if_fail (attr != NULL);
Packit ae235b
Packit ae235b
  _g_file_attribute_value_clear (attr);
Packit ae235b
  attr->type = G_FILE_ATTRIBUTE_TYPE_INT32;
Packit ae235b
  attr->u.int32 = value;
Packit ae235b
}
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * _g_file_attribute_value_set_uint64:
Packit ae235b
 * @attr: a #GFileAttributeValue.
Packit ae235b
 * @value: a #guint64 to set within the type.
Packit ae235b
 *
Packit ae235b
 * Sets the attribute value to a given unsigned 64-bit integer.
Packit ae235b
 */
Packit ae235b
void
Packit ae235b
_g_file_attribute_value_set_uint64 (GFileAttributeValue *attr,
Packit ae235b
				    guint64              value)
Packit ae235b
{
Packit ae235b
  g_return_if_fail (attr != NULL);
Packit ae235b
Packit ae235b
  _g_file_attribute_value_clear (attr);
Packit ae235b
  attr->type = G_FILE_ATTRIBUTE_TYPE_UINT64;
Packit ae235b
  attr->u.uint64 = value;
Packit ae235b
}
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * _g_file_attribute_value_set_int64:
Packit ae235b
 * @attr: a #GFileAttributeValue.
Packit ae235b
 * @value: a #gint64 to set within the type.
Packit ae235b
 *
Packit ae235b
 * Sets the attribute value to a given signed 64-bit integer.
Packit ae235b
 */
Packit ae235b
void
Packit ae235b
_g_file_attribute_value_set_int64 (GFileAttributeValue *attr,
Packit ae235b
				   gint64               value)
Packit ae235b
{
Packit ae235b
  g_return_if_fail (attr != NULL);
Packit ae235b
Packit ae235b
  _g_file_attribute_value_clear (attr);
Packit ae235b
  attr->type = G_FILE_ATTRIBUTE_TYPE_INT64;
Packit ae235b
  attr->u.int64 = value;
Packit ae235b
}
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * _g_file_attribute_value_set_object:
Packit ae235b
 * @attr: a #GFileAttributeValue.
Packit ae235b
 * @obj: a #GObject.
Packit ae235b
 *
Packit ae235b
 * Sets the attribute to contain the value @obj.
Packit ae235b
 * The @attr references the GObject internally.
Packit ae235b
 */
Packit ae235b
void
Packit ae235b
_g_file_attribute_value_set_object (GFileAttributeValue *attr,
Packit ae235b
				    GObject             *obj)
Packit ae235b
{
Packit ae235b
  g_return_if_fail (attr != NULL);
Packit ae235b
  g_return_if_fail (obj != NULL);
Packit ae235b
Packit ae235b
  _g_file_attribute_value_clear (attr);
Packit ae235b
  attr->type = G_FILE_ATTRIBUTE_TYPE_OBJECT;
Packit ae235b
  attr->u.obj = g_object_ref (obj);
Packit ae235b
}
Packit ae235b
Packit ae235b
typedef struct {
Packit ae235b
  GFileAttributeInfoList public;
Packit ae235b
  GArray *array;
Packit ae235b
  int ref_count;
Packit ae235b
} GFileAttributeInfoListPriv;
Packit ae235b
Packit ae235b
static void
Packit ae235b
list_update_public (GFileAttributeInfoListPriv *priv)
Packit ae235b
{
Packit ae235b
  priv->public.infos = (GFileAttributeInfo *)priv->array->data;
Packit ae235b
  priv->public.n_infos = priv->array->len;
Packit ae235b
}
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * g_file_attribute_info_list_new:
Packit ae235b
 *
Packit ae235b
 * Creates a new file attribute info list.
Packit ae235b
 *
Packit ae235b
 * Returns: a #GFileAttributeInfoList.
Packit ae235b
 */
Packit ae235b
GFileAttributeInfoList *
Packit ae235b
g_file_attribute_info_list_new (void)
Packit ae235b
{
Packit ae235b
  GFileAttributeInfoListPriv *priv;
Packit ae235b
Packit ae235b
  priv = g_new0 (GFileAttributeInfoListPriv, 1);
Packit ae235b
Packit ae235b
  priv->ref_count = 1;
Packit ae235b
  priv->array = g_array_new (TRUE, FALSE, sizeof (GFileAttributeInfo));
Packit ae235b
Packit ae235b
  list_update_public (priv);
Packit ae235b
Packit ae235b
  return (GFileAttributeInfoList *)priv;
Packit ae235b
}
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * g_file_attribute_info_list_dup:
Packit ae235b
 * @list: a #GFileAttributeInfoList to duplicate.
Packit ae235b
 *
Packit ae235b
 * Makes a duplicate of a file attribute info list.
Packit ae235b
 *
Packit ae235b
 * Returns: a copy of the given @list.
Packit ae235b
 */
Packit ae235b
GFileAttributeInfoList *
Packit ae235b
g_file_attribute_info_list_dup (GFileAttributeInfoList *list)
Packit ae235b
{
Packit ae235b
  GFileAttributeInfoListPriv *new;
Packit ae235b
  int i;
Packit ae235b
Packit ae235b
  g_return_val_if_fail (list != NULL, NULL);
Packit ae235b
Packit ae235b
  new = g_new0 (GFileAttributeInfoListPriv, 1);
Packit ae235b
  new->ref_count = 1;
Packit ae235b
  new->array = g_array_new (TRUE, FALSE, sizeof (GFileAttributeInfo));
Packit ae235b
Packit ae235b
  g_array_set_size (new->array, list->n_infos);
Packit ae235b
  list_update_public (new);
Packit ae235b
  for (i = 0; i < list->n_infos; i++)
Packit ae235b
    {
Packit ae235b
      new->public.infos[i].name = g_strdup (list->infos[i].name);
Packit ae235b
      new->public.infos[i].type = list->infos[i].type;
Packit ae235b
      new->public.infos[i].flags = list->infos[i].flags;
Packit ae235b
    }
Packit ae235b
Packit ae235b
  return (GFileAttributeInfoList *)new;
Packit ae235b
}
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * g_file_attribute_info_list_ref:
Packit ae235b
 * @list: a #GFileAttributeInfoList to reference.
Packit ae235b
 *
Packit ae235b
 * References a file attribute info list.
Packit ae235b
 *
Packit ae235b
 * Returns: #GFileAttributeInfoList or %NULL on error.
Packit ae235b
 */
Packit ae235b
GFileAttributeInfoList *
Packit ae235b
g_file_attribute_info_list_ref (GFileAttributeInfoList *list)
Packit ae235b
{
Packit ae235b
  GFileAttributeInfoListPriv *priv = (GFileAttributeInfoListPriv *)list;
Packit ae235b
Packit ae235b
  g_return_val_if_fail (list != NULL, NULL);
Packit ae235b
  g_return_val_if_fail (priv->ref_count > 0, NULL);
Packit ae235b
Packit ae235b
  g_atomic_int_inc (&priv->ref_count);
Packit ae235b
Packit ae235b
  return list;
Packit ae235b
}
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * g_file_attribute_info_list_unref:
Packit ae235b
 * @list: The #GFileAttributeInfoList to unreference.
Packit ae235b
 *
Packit ae235b
 * Removes a reference from the given @list. If the reference count
Packit ae235b
 * falls to zero, the @list is deleted.
Packit ae235b
 */
Packit ae235b
void
Packit ae235b
g_file_attribute_info_list_unref (GFileAttributeInfoList *list)
Packit ae235b
{
Packit ae235b
  GFileAttributeInfoListPriv *priv = (GFileAttributeInfoListPriv *)list;
Packit ae235b
  int i;
Packit ae235b
Packit ae235b
  g_return_if_fail (list != NULL);
Packit ae235b
  g_return_if_fail (priv->ref_count > 0);
Packit ae235b
Packit ae235b
  if (g_atomic_int_dec_and_test (&priv->ref_count))
Packit ae235b
    {
Packit ae235b
      for (i = 0; i < list->n_infos; i++)
Packit ae235b
        g_free (list->infos[i].name);
Packit ae235b
      g_array_free (priv->array, TRUE);
Packit ae235b
      g_free (list);
Packit ae235b
    }
Packit ae235b
}
Packit ae235b
Packit ae235b
static int
Packit ae235b
g_file_attribute_info_list_bsearch (GFileAttributeInfoList *list,
Packit ae235b
				    const char             *name)
Packit ae235b
{
Packit ae235b
  int start, end, mid;
Packit ae235b
Packit ae235b
  start = 0;
Packit ae235b
  end = list->n_infos;
Packit ae235b
Packit ae235b
  while (start != end)
Packit ae235b
    {
Packit ae235b
      mid = start + (end - start) / 2;
Packit ae235b
Packit ae235b
      if (strcmp (name, list->infos[mid].name) < 0)
Packit ae235b
	end = mid;
Packit ae235b
      else if (strcmp (name, list->infos[mid].name) > 0)
Packit ae235b
	start = mid + 1;
Packit ae235b
      else
Packit ae235b
	return mid;
Packit ae235b
    }
Packit ae235b
  return start;
Packit ae235b
}
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * g_file_attribute_info_list_lookup:
Packit ae235b
 * @list: a #GFileAttributeInfoList.
Packit ae235b
 * @name: the name of the attribute to lookup.
Packit ae235b
 *
Packit ae235b
 * Gets the file attribute with the name @name from @list.
Packit ae235b
 *
Packit ae235b
 * Returns: a #GFileAttributeInfo for the @name, or %NULL if an
Packit ae235b
 * attribute isn't found.
Packit ae235b
 */
Packit ae235b
const GFileAttributeInfo *
Packit ae235b
g_file_attribute_info_list_lookup (GFileAttributeInfoList *list,
Packit ae235b
				   const char             *name)
Packit ae235b
{
Packit ae235b
  int i;
Packit ae235b
Packit ae235b
  g_return_val_if_fail (list != NULL, NULL);
Packit ae235b
  g_return_val_if_fail (name != NULL, NULL);
Packit ae235b
Packit ae235b
  i = g_file_attribute_info_list_bsearch (list, name);
Packit ae235b
Packit ae235b
  if (i < list->n_infos && strcmp (list->infos[i].name, name) == 0)
Packit ae235b
    return &list->infos[i];
Packit ae235b
Packit ae235b
  return NULL;
Packit ae235b
}
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * g_file_attribute_info_list_add:
Packit ae235b
 * @list: a #GFileAttributeInfoList.
Packit ae235b
 * @name: the name of the attribute to add.
Packit ae235b
 * @type: the #GFileAttributeType for the attribute.
Packit ae235b
 * @flags: #GFileAttributeInfoFlags for the attribute.
Packit ae235b
 *
Packit ae235b
 * Adds a new attribute with @name to the @list, setting
Packit ae235b
 * its @type and @flags.
Packit ae235b
 */
Packit ae235b
void
Packit ae235b
g_file_attribute_info_list_add (GFileAttributeInfoList *list,
Packit ae235b
				const char             *name,
Packit ae235b
				GFileAttributeType      type,
Packit ae235b
				GFileAttributeInfoFlags flags)
Packit ae235b
{
Packit ae235b
  GFileAttributeInfoListPriv *priv = (GFileAttributeInfoListPriv *)list;
Packit ae235b
  GFileAttributeInfo info;
Packit ae235b
  int i;
Packit ae235b
Packit ae235b
  g_return_if_fail (list != NULL);
Packit ae235b
  g_return_if_fail (name != NULL);
Packit ae235b
Packit ae235b
  i = g_file_attribute_info_list_bsearch (list, name);
Packit ae235b
Packit ae235b
  if (i < list->n_infos && strcmp (list->infos[i].name, name) == 0)
Packit ae235b
    {
Packit ae235b
      list->infos[i].type = type;
Packit ae235b
      return;
Packit ae235b
    }
Packit ae235b
Packit ae235b
  info.name = g_strdup (name);
Packit ae235b
  info.type = type;
Packit ae235b
  info.flags = flags;
Packit ae235b
  g_array_insert_vals (priv->array, i, &info, 1);
Packit ae235b
Packit ae235b
  list_update_public (priv);
Packit ae235b
}