g_file_info_get/set_attribute_string*(): Document the UTF-8ness.

* gio/gfileattribute.c: (_g_file_attribute_value_get_string,
_g_file_attribute_value_set_string): These use
G_FILE_ATTRIBUTE_TYPE_STRING, which is documented as UTF-8, so
document these private functions as using UTF-8.
* gio/gfileinfo.c: (g_file_info_get_attribute_string,
g_file_info_set_attribute_string, and stringv versions):
Document that the strings are UTF-8 because the implementation uses
those private functions, that use UTF-8.

This helps language bindings (such as glibmm) whose API
distinguishes between known and unknown encodings.
This commit is contained in:
Murray Cumming 2011-03-11 09:59:09 +01:00
parent 9505ad05ee
commit c1a75ca783
2 changed files with 343 additions and 343 deletions

View File

@ -1,5 +1,5 @@
/* GIO - GLib Input, Output and Streaming Library /* GIO - GLib Input, Output and Streaming Library
* *
* Copyright (C) 2006-2007 Red Hat, Inc. * Copyright (C) 2006-2007 Red Hat, Inc.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
@ -35,29 +35,29 @@
* @short_description: Key-Value Paired File Attributes * @short_description: Key-Value Paired File Attributes
* @include: gio/gio.h * @include: gio/gio.h
* @see_also: #GFile, #GFileInfo * @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 * 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 * by a colon, e.g. "namespace:keyname". Namespaces are included to sort
* key-value pairs by namespaces for relevance. Keys can be retrived * key-value pairs by namespaces for relevance. Keys can be retrived
* using wildcards, e.g. "standard::*" will return all of the keys in the * using wildcards, e.g. "standard::*" will return all of the keys in the
* "standard" namespace. * "standard" namespace.
* *
* Values are stored within the list in #GFileAttributeValue structures. * Values are stored within the list in #GFileAttributeValue structures.
* Values can store different types, listed in the enum #GFileAttributeType. * Values can store different types, listed in the enum #GFileAttributeType.
* Upon creation of a #GFileAttributeValue, the type will be set to * Upon creation of a #GFileAttributeValue, the type will be set to
* %G_FILE_ATTRIBUTE_TYPE_INVALID. * %G_FILE_ATTRIBUTE_TYPE_INVALID.
* *
* The list of possible attributes for a filesystem (pointed to by a #GFile) is * 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 * availible as a #GFileAttributeInfoList. This list is queryable by key names
* as indicated earlier. * as indicated earlier.
* *
* Classes that implement #GFileIface will create a #GFileAttributeInfoList and * Classes that implement #GFileIface will create a #GFileAttributeInfoList and
* install default keys and values for their given file system, architecture, * install default keys and values for their given file system, architecture,
* and other possible implementation details (e.g., on a UNIX system, a file * 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). * attribute key will be registered for the user id for a given file).
* *
* <para> * <para>
* <table> * <table>
* <title>GFileAttributes Default Namespaces</title> * <title>GFileAttributes Default Namespaces</title>
@ -66,29 +66,29 @@
* </thead> * </thead>
* <tbody> * <tbody>
* <row><entry>"standard"</entry><entry>The "Standard" namespace. General file * <row><entry>"standard"</entry><entry>The "Standard" namespace. General file
* information that any application may need should be put in this namespace. * information that any application may need should be put in this namespace.
* Examples include the file's name, type, and size.</entry></row> * Examples include the file's name, type, and size.</entry></row>
* <row><entry>"etag"</entry><entry>The <link linkend="gfile-etag">"Entity Tag"</link> * <row><entry>"etag"</entry><entry>The <link linkend="gfile-etag">"Entity Tag"</link>
* namespace. Currently, the only key in this namespace is "value", which contains * namespace. Currently, the only key in this namespace is "value", which contains
* the value of the current entity tag.</entry></row> * the value of the current entity tag.</entry></row>
* <row><entry>"id"</entry><entry>The "Identification" namespace. This * <row><entry>"id"</entry><entry>The "Identification" namespace. This
* namespace is used by file managers and applications that list directories * namespace is used by file managers and applications that list directories
* to check for loops and to uniquely identify files.</entry></row> * to check for loops and to uniquely identify files.</entry></row>
* <row><entry>"access"</entry><entry>The "Access" namespace. Used to check * <row><entry>"access"</entry><entry>The "Access" namespace. Used to check
* if a user has the proper privilidges to access files and perform * if a user has the proper privilidges to access files and perform
* file operations. Keys in this namespace are made to be generic * file operations. Keys in this namespace are made to be generic
* and easily understood, e.g. the "can_read" key is %TRUE if * and easily understood, e.g. the "can_read" key is %TRUE if
* the current user has permission to read the file. UNIX permissions and * the current user has permission to read the file. UNIX permissions and
* NTFS ACLs in Windows should be mapped to these values.</entry></row> * NTFS ACLs in Windows should be mapped to these values.</entry></row>
* <row><entry>"mountable"</entry><entry>The "Mountable" namespace. Includes * <row><entry>"mountable"</entry><entry>The "Mountable" namespace. Includes
* simple boolean keys for checking if a file or path supports mount operations, e.g. * 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.</entry></row> * mount, unmount, eject. These are used for files of type %G_FILE_TYPE_MOUNTABLE.</entry></row>
* <row><entry>"time"</entry><entry>The "Time" namespace. Includes file * <row><entry>"time"</entry><entry>The "Time" namespace. Includes file
* access, changed, created times. </entry></row> * access, changed, created times. </entry></row>
* <row><entry>"unix"</entry><entry>The "Unix" namespace. Includes UNIX-specific * <row><entry>"unix"</entry><entry>The "Unix" namespace. Includes UNIX-specific
* information and may not be available for all files. Examples include * information and may not be available for all files. Examples include
* the UNIX "UID", "GID", etc.</entry></row> * the UNIX "UID", "GID", etc.</entry></row>
* <row><entry>"dos"</entry><entry>The "DOS" namespace. Includes DOS-specific * <row><entry>"dos"</entry><entry>The "DOS" namespace. Includes DOS-specific
* information and may not be available for all files. Examples include * 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" * "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.</entry></row> * for checking if a file is marked as an archive file.</entry></row>
@ -96,8 +96,8 @@
* about who owns a file. May not be available for all file systems. Examples include * 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 * "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.</entry></row> * some backend specific data such as a unix UID.</entry></row>
* <row><entry>"thumbnail"</entry><entry>The "Thumbnail" namespace. Includes * <row><entry>"thumbnail"</entry><entry>The "Thumbnail" namespace. Includes
* information about file thumbnails and their location within the file system. Exaples of * 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" * keys in this namespace include "path" to get the location of a thumbnail, and "failed"
* to check if thumbnailing of the file failed.</entry></row> * to check if thumbnailing of the file failed.</entry></row>
* <row><entry>"filesystem"</entry><entry>The "Filesystem" namespace. Gets information * <row><entry>"filesystem"</entry><entry>The "Filesystem" namespace. Gets information
@ -105,14 +105,14 @@
* space is left available, and the overall size of the file system.</entry></row> * space is left available, and the overall size of the file system.</entry></row>
* <row><entry>"gvfs"</entry><entry>The "GVFS" namespace. Keys in this namespace * <row><entry>"gvfs"</entry><entry>The "GVFS" namespace. Keys in this namespace
* contain information about the current GVFS backend in use. </entry></row> * contain information about the current GVFS backend in use. </entry></row>
* <row><entry>"xattr"</entry><entry>The "xattr" namespace. Gets information * <row><entry>"xattr"</entry><entry>The "xattr" namespace. Gets information
* about extended user attributes. See attr(5). The "user." prefix of the * about extended user attributes. See attr(5). The "user." prefix of the
* extended user attribute name is stripped away when constructing keys in * extended user attribute name is stripped away when constructing keys in
* this namespace, e.g. "xattr::mime_type" for the extended attribute with * this namespace, e.g. "xattr::mime_type" for the extended attribute with
* the name "user.mime_type". Note that this information is only available * the name "user.mime_type". Note that this information is only available
* if GLib has been built with extended attribute support.</entry></row> * if GLib has been built with extended attribute support.</entry></row>
* <row><entry>"xattr-sys"</entry><entry>The "xattr-sys" namespace. * <row><entry>"xattr-sys"</entry><entry>The "xattr-sys" namespace.
* Gets information about extended attributes which are not user-specific. * Gets information about extended attributes which are not user-specific.
* See attr(5). Note that this information is only available if GLib * See attr(5). Note that this information is only available if GLib
* has been built with extended attribute support.</entry></row> * has been built with extended attribute support.</entry></row>
* <row><entry>"selinux"</entry><entry>The "SELinux" namespace. Includes * <row><entry>"selinux"</entry><entry>The "SELinux" namespace. Includes
@ -122,14 +122,14 @@
* </tgroup> * </tgroup>
* </table> * </table>
* </para> * </para>
* *
* Please note that these are not all of the possible namespaces. * 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. * For more information about writing GIO modules, see #GIOModule.
* *
* <!-- TODO: Implementation note about using extended attributes on supported * <!-- TODO: Implementation note about using extended attributes on supported
* file systems --> * file systems -->
* *
* <para><table> * <para><table>
* <title>GFileAttributes Built-in Keys and Value Types</title> * <title>GFileAttributes Built-in Keys and Value Types</title>
* <tgroup cols='3' align='left'><thead> * <tgroup cols='3' align='left'><thead>
@ -199,21 +199,21 @@
* <row><entry>%G_FILE_ATTRIBUTE_GVFS_BACKEND</entry><entry>gvfs::backend</entry><entry>string</entry></row> * <row><entry>%G_FILE_ATTRIBUTE_GVFS_BACKEND</entry><entry>gvfs::backend</entry><entry>string</entry></row>
* <row><entry>%G_FILE_ATTRIBUTE_SELINUX_CONTEXT</entry><entry>selinux::context</entry><entry>string</entry></row> * <row><entry>%G_FILE_ATTRIBUTE_SELINUX_CONTEXT</entry><entry>selinux::context</entry><entry>string</entry></row>
* </tbody></tgroup></table></para> * </tbody></tgroup></table></para>
* *
* Note that there are no predefined keys in the "xattr" and "xattr-sys" * Note that there are no predefined keys in the "xattr" and "xattr-sys"
* namespaces. Keys for the "xattr" namespace are constructed by stripping * namespaces. Keys for the "xattr" namespace are constructed by stripping
* away the "user." prefix from the extended user attribute, and prepending * 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 * concatenating "xattr-sys::" with the extended attribute name. All extended
* attribute values are returned as hex-encoded strings in which bytes outside * attribute values are returned as hex-encoded strings in which bytes outside
* the ASCII range are encoded as hexadecimal escape sequences of the form * the ASCII range are encoded as hexadecimal escape sequences of the form
* \x<replaceable>nn</replaceable>. * \x<replaceable>nn</replaceable>.
**/ **/
/* /*
* _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.
* *
**/ **/
@ -230,9 +230,9 @@ _g_file_attribute_value_free (GFileAttributeValue *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
* %G_FILE_ATTRIBUTE_TYPE_INVALID. * %G_FILE_ATTRIBUTE_TYPE_INVALID.
* *
**/ **/
void void
_g_file_attribute_value_clear (GFileAttributeValue *attr) _g_file_attribute_value_clear (GFileAttributeValue *attr)
@ -242,14 +242,14 @@ _g_file_attribute_value_clear (GFileAttributeValue *attr)
if (attr->type == G_FILE_ATTRIBUTE_TYPE_STRING || if (attr->type == G_FILE_ATTRIBUTE_TYPE_STRING ||
attr->type == G_FILE_ATTRIBUTE_TYPE_BYTE_STRING) attr->type == G_FILE_ATTRIBUTE_TYPE_BYTE_STRING)
g_free (attr->u.string); g_free (attr->u.string);
if (attr->type == G_FILE_ATTRIBUTE_TYPE_STRINGV) if (attr->type == G_FILE_ATTRIBUTE_TYPE_STRINGV)
g_strfreev (attr->u.stringv); g_strfreev (attr->u.stringv);
if (attr->type == G_FILE_ATTRIBUTE_TYPE_OBJECT && if (attr->type == G_FILE_ATTRIBUTE_TYPE_OBJECT &&
attr->u.obj != NULL) attr->u.obj != NULL)
g_object_unref (attr->u.obj); g_object_unref (attr->u.obj);
attr->type = G_FILE_ATTRIBUTE_TYPE_INVALID; attr->type = G_FILE_ATTRIBUTE_TYPE_INVALID;
} }
@ -257,7 +257,7 @@ _g_file_attribute_value_clear (GFileAttributeValue *attr)
* 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.
* *
* Sets an attribute's value from another attribute. * Sets an attribute's value from another attribute.
**/ **/
void void
@ -273,7 +273,7 @@ _g_file_attribute_value_set (GFileAttributeValue *attr,
if (attr->type == G_FILE_ATTRIBUTE_TYPE_STRING || if (attr->type == G_FILE_ATTRIBUTE_TYPE_STRING ||
attr->type == G_FILE_ATTRIBUTE_TYPE_BYTE_STRING) attr->type == G_FILE_ATTRIBUTE_TYPE_BYTE_STRING)
attr->u.string = g_strdup (attr->u.string); attr->u.string = g_strdup (attr->u.string);
if (attr->type == G_FILE_ATTRIBUTE_TYPE_STRINGV) if (attr->type == G_FILE_ATTRIBUTE_TYPE_STRINGV)
attr->u.stringv = g_strdupv (attr->u.stringv); attr->u.stringv = g_strdupv (attr->u.stringv);
@ -284,9 +284,9 @@ _g_file_attribute_value_set (GFileAttributeValue *attr,
/* /*
* _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 *
@ -318,9 +318,9 @@ _g_file_attribute_value_peek_as_pointer (GFileAttributeValue *attr)
/* /*
* g_file_attribute_value_dup: * g_file_attribute_value_dup:
* @other: a #GFileAttributeValue to duplicate. * @other: a #GFileAttributeValue to duplicate.
* *
* Duplicates a file attribute. * Duplicates a file attribute.
* *
* Returns: a duplicate of the @other. * Returns: a duplicate of the @other.
**/ **/
GFileAttributeValue * GFileAttributeValue *
@ -466,7 +466,7 @@ _g_file_attribute_value_as_string (const GFileAttributeValue *attr)
* Gets the string from a file attribute value. If the value is not the * Gets the string from a file attribute value. If the value is not the
* right type then %NULL will be returned. * 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 * const char *
_g_file_attribute_value_get_string (const GFileAttributeValue *attr) _g_file_attribute_value_get_string (const GFileAttributeValue *attr)
@ -695,9 +695,9 @@ _g_file_attribute_value_set_from_pointer (GFileAttributeValue *value,
/* /*
* _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 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 void
_g_file_attribute_value_set_string (GFileAttributeValue *attr, _g_file_attribute_value_set_string (GFileAttributeValue *attr,

File diff suppressed because it is too large Load Diff