X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gio%2Fgfileattribute.c;h=09f01c00af46fde66231a2676050d2584ed7e9c4;hb=a3d86afa81ff34ce797a3928fd619ead219a37af;hp=3a50f4b45ee0f6b0b36df4c781f4cad093cc5a26;hpb=5b946e0504952a472cea1ef95df0967e8a4a7b47;p=platform%2Fupstream%2Fglib.git
diff --git a/gio/gfileattribute.c b/gio/gfileattribute.c
index 3a50f4b..09f01c0 100644
--- a/gio/gfileattribute.c
+++ b/gio/gfileattribute.c
@@ -1,5 +1,5 @@
/* 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
@@ -13,9 +13,7 @@
* 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.
+ * Public License along with this library; if not, see .
*
* Author: Alexander Larsson
*/
@@ -35,185 +33,112 @@
* @short_description: Key-Value Paired File Attributes
* @include: gio/gio.h
* @see_also: #GFile, #GFileInfo
- *
- * File attributes in GIO consist of a list of key-value pairs.
- *
+ *
+ * File attributes in GIO consist of a list of key-value pairs.
+ *
* Keys are strings that contain a key namespace and a key name, separated
- * by a colon, e.g. "namespace:keyname". Namespaces are included to sort
- * key-value pairs by namespaces for relevance. Keys can be retrived
- * using wildcards, e.g. "standard::*" will return all of the keys in the
+ * by a colon, e.g. "namespace::keyname". Namespaces are included to sort
+ * key-value pairs by namespaces for relevance. Keys can be retrived
+ * using wildcards, e.g. "standard::*" will return all of the keys in the
* "standard" namespace.
- *
- * Values are stored within the list in #GFileAttributeValue structures.
- * Values can store different types, listed in the enum #GFileAttributeType.
- * Upon creation of a #GFileAttributeValue, the type will be set to
- * %G_FILE_ATTRIBUTE_TYPE_INVALID.
- *
+ *
* The list of possible attributes for a filesystem (pointed to by a #GFile) is
- * availible as a #GFileAttributeInfoList. This list is queryable by key names
+ * available as a #GFileAttributeInfoList. This list is queryable by key names
* as indicated earlier.
- *
- * Classes that implement #GFileIface will create a #GFileAttributeInfoList and
- * install default keys and values for their given file system, architecture,
- * and other possible implementation details (e.g., on a UNIX system, a file
+ *
+ * Information is stored within the list in #GFileAttributeInfo structures.
+ * The info structure can store different types, listed in the enum
+ * #GFileAttributeType. Upon creation of a #GFileAttributeInfo, the type will
+ * be set to %G_FILE_ATTRIBUTE_TYPE_INVALID.
+ *
+ * Classes that implement #GFileIface will create a #GFileAttributeInfoList and
+ * install default keys and values for their given file system, architecture,
+ * and other possible implementation details (e.g., on a UNIX system, a file
* attribute key will be registered for the user id for a given file).
- *
- *
- *
- * GFileAttributes Default Namespaces
- *
- * NamspaceDescription
- *
- *
- * "standard"The "Standard" namespace. General file
- * information that any application may need should be put in this namespace.
- * Examples include the file's name, type, and size.
- * "etag"The "Entity Tag"
- * namespace. Currently, the only key in this namespace is "value", which contains
- * the value of the current entity tag.
- * "id"The "Identification" namespace. This
- * namespace is used by file managers and applications that list directories
- * to check for loops and to uniquely identify files.
- * "access"The "Access" namespace. Used to check
- * if a user has the proper privilidges to access files and perform
- * file operations. Keys in this namespace are made to be generic
- * and easily understood, e.g. the "can_read" key is %TRUE if
- * the current user has permission to read the file. UNIX permissions and
- * NTFS ACLs in Windows should be mapped to these values.
- * "mountable"The "Mountable" namespace. Includes
- * simple boolean keys for checking if a file or path supports mount operations, e.g.
- * mount, unmount, eject. These are used for files of type %G_FILE_TYPE_MOUNTABLE.
- * "time"The "Time" namespace. Includes file
- * access, changed, created times.
- * "unix"The "Unix" namespace. Includes UNIX-specific
- * information and may not be available for all files. Examples include
- * the UNIX "UID", "GID", etc.
- * "dos"The "DOS" namespace. Includes DOS-specific
- * information and may not be available for all files. Examples include
- * "is_system" for checking if a file is marked as a system file, and "is_archive"
- * for checking if a file is marked as an archive file.
- * "owner"The "Owner" namespace. Includes information
- * about who owns a file. May not be available for all file systems. Examples include
- * "user" for getting the user name of the file owner. This information is often mapped from
- * some backend specific data such as a unix UID.
- * "thumbnail"The "Thumbnail" namespace. Includes
- * information about file thumbnails and their location within the file system. Exaples of
- * keys in this namespace include "path" to get the location of a thumbnail, and "failed"
- * to check if thumbnailing of the file failed.
- * "filesystem"The "Filesystem" namespace. Gets information
- * about the file system where a file is located, such as its type, how much
- * space is left available, and the overall size of the file system.
- * "gvfs"The "GVFS" namespace. Keys in this namespace
- * contain information about the current GVFS backend in use.
- * "xattr"The "xattr" namespace. Gets information
- * about extended user attributes. See attr(5). The "user." prefix of the
- * extended user attribute name is stripped away when constructing keys in
- * this namespace, e.g. "xattr::mime_type" for the extended attribute with
- * the name "user.mime_type". Note that this information is only available
- * if GLib has been built with extended attribute support.
- * "xattr-sys"The "xattr-sys" namespace.
- * Gets information about extended attributes which are not user-specific.
- * See attr(5). Note that this information is only available if GLib
- * has been built with extended attribute support.
- * "selinux"The "SELinux" namespace. Includes
- * information about the SELinux context of files. Note that this information
- * is only available if GLib has been built with SELinux support.
- *
- *
- *
- *
- *
+ *
+ * ## Default Namespaces
+ *
+ * - `"standard"`: The "Standard" namespace. General file information that
+ * any application may need should be put in this namespace. Examples
+ * include the file's name, type, and size.
+ * - `"etag`: The [Entity Tag][gfile-etag] namespace. Currently, the only key
+ * in this namespace is "value", which contains the value of the current
+ * entity tag.
+ * - `"id"`: The "Identification" namespace. This namespace is used by file
+ * managers and applications that list directories to check for loops and
+ * to uniquely identify files.
+ * - `"access"`: The "Access" namespace. Used to check if a user has the
+ * proper privileges to access files and perform file operations. Keys in
+ * this namespace are made to be generic and easily understood, e.g. the
+ * "can_read" key is %TRUE if the current user has permission to read the
+ * file. UNIX permissions and NTFS ACLs in Windows should be mapped to
+ * these values.
+ * - `"mountable"`: The "Mountable" namespace. Includes simple boolean keys
+ * for checking if a file or path supports mount operations, e.g. mount,
+ * unmount, eject. These are used for files of type %G_FILE_TYPE_MOUNTABLE.
+ * - `"time"`: The "Time" namespace. Includes file access, changed, created
+ * times.
+ * - `"unix"`: The "Unix" namespace. Includes UNIX-specific information and
+ * may not be available for all files. Examples include the UNIX "UID",
+ * "GID", etc.
+ * - `"dos"`: The "DOS" namespace. Includes DOS-specific information and may
+ * not be available for all files. Examples include "is_system" for checking
+ * if a file is marked as a system file, and "is_archive" for checking if a
+ * file is marked as an archive file.
+ * - `"owner"`: The "Owner" namespace. Includes information about who owns a
+ * file. May not be available for all file systems. Examples include "user"
+ * for getting the user name of the file owner. This information is often
+ * mapped from some backend specific data such as a UNIX UID.
+ * - `"thumbnail"`: The "Thumbnail" namespace. Includes information about file
+ * thumbnails and their location within the file system. Examples of keys in
+ * this namespace include "path" to get the location of a thumbnail, "failed"
+ * to check if thumbnailing of the file failed, and "is-valid" to check if
+ * the thumbnail is outdated.
+ * - `"filesystem"`: The "Filesystem" namespace. Gets information about the
+ * file system where a file is located, such as its type, how much space is
+ * left available, and the overall size of the file system.
+ * - `"gvfs"`: The "GVFS" namespace. Keys in this namespace contain information
+ * about the current GVFS backend in use.
+ * - `"xattr"`: The "xattr" namespace. Gets information about extended
+ * user attributes. See attr(5). The "user." prefix of the extended user
+ * attribute name is stripped away when constructing keys in this namespace,
+ * e.g. "xattr::mime_type" for the extended attribute with the name
+ * "user.mime_type". Note that this information is only available if
+ * GLib has been built with extended attribute support.
+ * - `"xattr-sys"`: The "xattr-sys" namespace. Gets information about
+ * extended attributes which are not user-specific. See attr(5). Note
+ * that this information is only available if GLib has been built with
+ * extended attribute support.
+ * - `"selinux"`: The "SELinux" namespace. Includes information about the
+ * SELinux context of files. Note that this information is only available
+ * if GLib has been built with SELinux support.
+ *
* Please note that these are not all of the possible namespaces.
- * More namespaces can be added from GIO modules or by individual applications.
+ * More namespaces can be added from GIO modules or by individual applications.
* For more information about writing GIO modules, see #GIOModule.
*
- *
- *
- *
- *
- * Note that there are no predefined keys in the "xattr" and "xattr-sys"
+ *
+ * ## Default Keys
+ *
+ * For a list of the built-in keys and their types, see the
+ * [GFileInfo][GFileInfo] documentation.
+ *
+ * Note that there are no predefined keys in the "xattr" and "xattr-sys"
* namespaces. Keys for the "xattr" namespace are constructed by stripping
* away the "user." prefix from the extended user attribute, and prepending
- * "xattr::". Keys for the "xattr-sys" namespace are constructed by
+ * "xattr::". Keys for the "xattr-sys" namespace are constructed by
* concatenating "xattr-sys::" with the extended attribute name. All extended
* attribute values are returned as hex-encoded strings in which bytes outside
- * the ASCII range are encoded as hexadecimal escape sequences of the form
- * \xnn.
- **/
+ * the ASCII range are encoded as escape sequences of the form \x`nn`
+ * where `nn` is a 2-digit hexadecimal number.
+ */
-/*
+/**
* _g_file_attribute_value_free:
- * @attr: a #GFileAttributeValue.
- *
+ * @attr: a #GFileAttributeValue.
+ *
* Frees the memory used by @attr.
*
**/
@@ -226,13 +151,13 @@ _g_file_attribute_value_free (GFileAttributeValue *attr)
g_free (attr);
}
-/*
+/**
* _g_file_attribute_value_clear:
* @attr: a #GFileAttributeValue.
*
- * Clears the value of @attr and sets its type to
+ * Clears the value of @attr and sets its type to
* %G_FILE_ATTRIBUTE_TYPE_INVALID.
- *
+ *
**/
void
_g_file_attribute_value_clear (GFileAttributeValue *attr)
@@ -242,22 +167,22 @@ _g_file_attribute_value_clear (GFileAttributeValue *attr)
if (attr->type == G_FILE_ATTRIBUTE_TYPE_STRING ||
attr->type == G_FILE_ATTRIBUTE_TYPE_BYTE_STRING)
g_free (attr->u.string);
-
+
if (attr->type == G_FILE_ATTRIBUTE_TYPE_STRINGV)
g_strfreev (attr->u.stringv);
if (attr->type == G_FILE_ATTRIBUTE_TYPE_OBJECT &&
attr->u.obj != NULL)
g_object_unref (attr->u.obj);
-
+
attr->type = G_FILE_ATTRIBUTE_TYPE_INVALID;
}
-/*
+/**
* g_file_attribute_value_set:
* @attr: a #GFileAttributeValue to set the value in.
* @new_value: a #GFileAttributeValue to get the value from.
- *
+ *
* Sets an attribute's value from another attribute.
**/
void
@@ -273,7 +198,7 @@ _g_file_attribute_value_set (GFileAttributeValue *attr,
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_STRINGV)
attr->u.stringv = g_strdupv (attr->u.stringv);
@@ -282,11 +207,11 @@ _g_file_attribute_value_set (GFileAttributeValue *attr,
g_object_ref (attr->u.obj);
}
-/*
+/**
* _g_file_attribute_value_new:
- *
+ *
* Creates a new file attribute.
- *
+ *
* Returns: a #GFileAttributeValue.
**/
GFileAttributeValue *
@@ -315,12 +240,12 @@ _g_file_attribute_value_peek_as_pointer (GFileAttributeValue *attr)
}
}
-/*
+/**
* g_file_attribute_value_dup:
* @other: a #GFileAttributeValue to duplicate.
- *
+ *
* Duplicates a file attribute.
- *
+ *
* Returns: a duplicate of the @other.
**/
GFileAttributeValue *
@@ -336,23 +261,9 @@ _g_file_attribute_value_dup (const GFileAttributeValue *other)
return attr;
}
-GType
-g_file_attribute_info_list_get_type (void)
-{
- static volatile gsize g_define_type_id__volatile = 0;
-
- if (g_once_init_enter (&g_define_type_id__volatile))
- {
- GType g_define_type_id =
- g_boxed_type_register_static (I_("GFileAttributeInfoList"),
- (GBoxedCopyFunc) g_file_attribute_info_list_dup,
- (GBoxedFreeFunc) g_file_attribute_info_list_unref);
-
- g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
- }
-
- return g_define_type_id__volatile;
-}
+G_DEFINE_BOXED_TYPE (GFileAttributeInfoList, g_file_attribute_info_list,
+ g_file_attribute_info_list_dup,
+ g_file_attribute_info_list_unref)
static gboolean
valid_char (char c)
@@ -403,14 +314,14 @@ escape_byte_string (const char *str)
}
}
-/*
+/**
* _g_file_attribute_value_as_string:
* @attr: a #GFileAttributeValue.
*
* Converts a #GFileAttributeValue to a string for display.
* The returned string should be freed when no longer needed.
*
- * Returns: a string from the @attr, %NULL on error, or "<invalid>"
+ * Returns: a string from the @attr, %NULL on error, or ""
* if @attr is of type %G_FILE_ATTRIBUTE_TYPE_INVALID.
*/
char *
@@ -473,14 +384,14 @@ _g_file_attribute_value_as_string (const GFileAttributeValue *attr)
return str;
}
-/*
+/**
* _g_file_attribute_value_get_string:
* @attr: a #GFileAttributeValue.
*
* Gets the string from a file attribute value. If the value is not the
* right type then %NULL will be returned.
*
- * Returns: the string value contained within the attribute, or %NULL.
+ * Returns: the UTF-8 string value contained within the attribute, or %NULL.
*/
const char *
_g_file_attribute_value_get_string (const GFileAttributeValue *attr)
@@ -493,7 +404,7 @@ _g_file_attribute_value_get_string (const GFileAttributeValue *attr)
return attr->u.string;
}
-/*
+/**
* _g_file_attribute_value_get_byte_string:
* @attr: a #GFileAttributeValue.
*
@@ -524,7 +435,7 @@ _g_file_attribute_value_get_stringv (const GFileAttributeValue *attr)
return attr->u.stringv;
}
-/*
+/**
* _g_file_attribute_value_get_boolean:
* @attr: a #GFileAttributeValue.
*
@@ -544,7 +455,7 @@ _g_file_attribute_value_get_boolean (const GFileAttributeValue *attr)
return attr->u.boolean;
}
-/*
+/**
* _g_file_attribute_value_get_uint32:
* @attr: a #GFileAttributeValue.
*
@@ -564,7 +475,7 @@ _g_file_attribute_value_get_uint32 (const GFileAttributeValue *attr)
return attr->u.uint32;
}
-/*
+/**
* _g_file_attribute_value_get_int32:
* @attr: a #GFileAttributeValue.
*
@@ -584,7 +495,7 @@ _g_file_attribute_value_get_int32 (const GFileAttributeValue *attr)
return attr->u.int32;
}
-/*
+/**
* _g_file_attribute_value_get_uint64:
* @attr: a #GFileAttributeValue.
*
@@ -604,7 +515,7 @@ _g_file_attribute_value_get_uint64 (const GFileAttributeValue *attr)
return attr->u.uint64;
}
-/*
+/**
* _g_file_attribute_value_get_int64:
* @attr: a #GFileAttributeValue.
*
@@ -624,7 +535,7 @@ _g_file_attribute_value_get_int64 (const GFileAttributeValue *attr)
return attr->u.int64;
}
-/*
+/**
* _g_file_attribute_value_get_object:
* @attr: a #GFileAttributeValue.
*
@@ -706,12 +617,12 @@ _g_file_attribute_value_set_from_pointer (GFileAttributeValue *value,
}
}
-/*
+/**
* _g_file_attribute_value_set_string:
* @attr: a #GFileAttributeValue.
- * @string: a string to set within the type.
+ * @string: a UTF-8 string to set within the type.
*
- * Sets the attribute value to a given string.
+ * Sets the attribute value to a given UTF-8 string.
*/
void
_g_file_attribute_value_set_string (GFileAttributeValue *attr,
@@ -725,7 +636,7 @@ _g_file_attribute_value_set_string (GFileAttributeValue *attr,
attr->u.string = g_strdup (string);
}
-/*
+/**
* _g_file_attribute_value_set_byte_string:
* @attr: a #GFileAttributeValue.
* @string: a byte string to set within the type.
@@ -757,7 +668,7 @@ _g_file_attribute_value_set_stringv (GFileAttributeValue *attr,
}
-/*
+/**
* _g_file_attribute_value_set_boolean:
* @attr: a #GFileAttributeValue.
* @value: a #gboolean to set within the type.
@@ -775,7 +686,7 @@ _g_file_attribute_value_set_boolean (GFileAttributeValue *attr,
attr->u.boolean = !!value;
}
-/*
+/**
* _g_file_attribute_value_set_uint32:
* @attr: a #GFileAttributeValue.
* @value: a #guint32 to set within the type.
@@ -793,7 +704,7 @@ _g_file_attribute_value_set_uint32 (GFileAttributeValue *attr,
attr->u.uint32 = value;
}
-/*
+/**
* _g_file_attribute_value_set_int32:
* @attr: a #GFileAttributeValue.
* @value: a #gint32 to set within the type.
@@ -811,7 +722,7 @@ _g_file_attribute_value_set_int32 (GFileAttributeValue *attr,
attr->u.int32 = value;
}
-/*
+/**
* _g_file_attribute_value_set_uint64:
* @attr: a #GFileAttributeValue.
* @value: a #guint64 to set within the type.
@@ -829,7 +740,7 @@ _g_file_attribute_value_set_uint64 (GFileAttributeValue *attr,
attr->u.uint64 = value;
}
-/*
+/**
* _g_file_attribute_value_set_int64:
* @attr: a #GFileAttributeValue.
* @value: a #gint64 to set within the type.
@@ -847,7 +758,7 @@ _g_file_attribute_value_set_int64 (GFileAttributeValue *attr,
attr->u.int64 = value;
}
-/*
+/**
* _g_file_attribute_value_set_object:
* @attr: a #GFileAttributeValue.
* @obj: a #GObject.
@@ -976,6 +887,7 @@ g_file_attribute_info_list_unref (GFileAttributeInfoList *list)
for (i = 0; i < list->n_infos; i++)
g_free (list->infos[i].name);
g_array_free (priv->array, TRUE);
+ g_free (list);
}
}