Use g_simple_async_result_{new_,}take_error
[platform/upstream/glib.git] / gio / gfile.c
index b694ef3..f84e592 100644 (file)
@@ -50,7 +50,6 @@
 #include "gioerror.h"
 #include "glibintl.h"
 
-#include "gioalias.h"
 
 /**
  * SECTION:gfile
@@ -522,7 +521,7 @@ g_file_get_parse_name (GFile *file)
  *
  * This call does no blocking i/o.
  * 
- * Returns: a new #GFile that is a duplicate of the given #GFile. 
+ * Returns: (transfer full): a new #GFile that is a duplicate of the given #GFile. 
  **/
 GFile *
 g_file_dup (GFile *file)
@@ -543,7 +542,8 @@ g_file_dup (GFile *file)
  * Creates a hash value for a #GFile.
  *
  * This call does no blocking i/o.
- * 
+ *
+ * Virtual: hash
  * Returns: 0 if @file is not a valid #GFile, otherwise an 
  *     integer that can be used as hash value for the #GFile. 
  *     This function is intended for easily hashing a #GFile to 
@@ -604,7 +604,7 @@ g_file_equal (GFile *file1,
  *
  * This call does no blocking i/o.
  * 
- * Returns: a #GFile structure to the parent of the given
+ * Returns: (transfer full): a #GFile structure to the parent of the given
  *     #GFile or %NULL if there is no parent. 
  *     Free the returned object with g_object_unref().
  **/
@@ -676,7 +676,7 @@ g_file_has_parent (GFile *file,
  *
  * This call does no blocking i/o.
  * 
- * Returns: a #GFile to a child specified by @name.
+ * Returns: (transfer full): a #GFile to a child specified by @name.
  *     Free the returned object with g_object_unref().
  **/
 GFile *
@@ -703,7 +703,7 @@ g_file_get_child (GFile      *file,
  * 
  * This call does no blocking i/o.
  * 
- * Returns: a #GFile to the specified child, or 
+ * Returns: (transfer full): a #GFile to the specified child, or 
  *     %NULL if the display name couldn't be converted.  
  *     Free the returned object with g_object_unref().
  **/
@@ -737,6 +737,7 @@ g_file_get_child_for_display_name (GFile      *file,
  * filesystem point of view), because the prefix of @file is an alias 
  * of @prefix.
  *
+ * Virtual: prefix_matches
  * Returns:  %TRUE if the @files's parent, grandparent, etc is @prefix. 
  *     %FALSE otherwise.
  **/
@@ -798,7 +799,7 @@ g_file_get_relative_path (GFile *parent,
  *
  * This call does no blocking i/o.
  * 
- * Returns: #GFile to the resolved path. %NULL if @relative_path 
+ * Returns: (transfer full): #GFile to the resolved path. %NULL if @relative_path 
  *     is %NULL or if @file is invalid.
  *     Free the returned object with g_object_unref().
  **/
@@ -828,10 +829,10 @@ g_file_resolve_relative_path (GFile      *file,
  * is a #GFileEnumerator object that will give out #GFileInfo objects for
  * all the files in the directory.
  *
- * The @attribute value is a string that specifies the file attributes that
+ * The @attributes value is a string that specifies the file attributes that
  * should be gathered. It is not an error if it's not possible to read a particular
- * requested attribute from a file - it just won't be set. @attribute should
- * be a comma-separated list of attribute or attribute wildcards. The wildcard "*"
+ * requested attribute from a file - it just won't be set. @attributes should
+ * be a comma-separated list of attributes or attribute wildcards. The wildcard "*"
  * means all attributes, and a wildcard like "standard::*" means all attributes in the standard
  * namespace. An example attribute query be "standard::*,owner::user".
  * The standard attributes are available as defines, like #G_FILE_ATTRIBUTE_STANDARD_NAME.
@@ -844,7 +845,7 @@ g_file_resolve_relative_path (GFile      *file,
  * If the file is not a directory, the G_FILE_ERROR_NOTDIR error will be returned.
  * Other errors are possible too.
  *
- * Returns: A #GFileEnumerator if successful, %NULL on error. 
+ * Returns: (transfer full): A #GFileEnumerator if successful, %NULL on error. 
  *     Free the returned object with g_object_unref().
  **/
 GFileEnumerator *
@@ -929,7 +930,7 @@ g_file_enumerate_children_async (GFile               *file,
  * Finishes an async enumerate children operation.
  * See g_file_enumerate_children_async().
  *
- * Returns: a #GFileEnumerator or %NULL if an error occurred.
+ * Returns: (transfer full): a #GFileEnumerator or %NULL if an error occurred.
  *     Free the returned object with g_object_unref().
  **/
 GFileEnumerator *
@@ -1053,10 +1054,10 @@ g_file_query_file_type (GFile *file,
  * is a #GFileInfo object that contains key-value attributes (such as 
  * the type or size of the file).
  *
- * The @attribute value is a string that specifies the file attributes that
+ * The @attributes value is a string that specifies the file attributes that
  * should be gathered. It is not an error if it's not possible to read a particular
- * requested attribute from a file - it just won't be set. @attribute should
- * be a comma-separated list of attribute or attribute wildcards. The wildcard "*"
+ * requested attribute from a file - it just won't be set. @attributes should
+ * be a comma-separated list of attributes or attribute wildcards. The wildcard "*"
  * means all attributes, and a wildcard like "standard::*" means all attributes in the standard
  * namespace. An example attribute query be "standard::*,owner::user".
  * The standard attributes are available as defines, like #G_FILE_ATTRIBUTE_STANDARD_NAME.
@@ -1075,7 +1076,7 @@ g_file_query_file_type (GFile *file,
  * If the file does not exist, the G_IO_ERROR_NOT_FOUND error will be returned.
  * Other errors are possible too, and depend on what kind of filesystem the file is on.
  *
- * Returns: a #GFileInfo for the given @file, or %NULL on error.
+ * Returns: (transfer full): a #GFileInfo for the given @file, or %NULL on error.
  *     Free the returned object with g_object_unref().
  **/
 GFileInfo *
@@ -1158,7 +1159,7 @@ g_file_query_info_async (GFile               *file,
  * Finishes an asynchronous file info query. 
  * See g_file_query_info_async().
  * 
- * Returns: #GFileInfo for given @file or %NULL on error.
+ * Returns: (transfer full): #GFileInfo for given @file or %NULL on error.
  *     Free the returned object with g_object_unref().
  **/
 GFileInfo *
@@ -1194,10 +1195,10 @@ g_file_query_info_finish (GFile         *file,
  * For instance the amount of space available and the type of
  * the filesystem.
  *
- * The @attribute value is a string that specifies the file attributes that
+ * The @attributes value is a string that specifies the file attributes that
  * should be gathered. It is not an error if it's not possible to read a particular
- * requested attribute from a file - it just won't be set. @attribute should
- * be a comma-separated list of attribute or attribute wildcards. The wildcard "*"
+ * requested attribute from a file - it just won't be set. @attributes should
+ * be a comma-separated list of attributes or attribute wildcards. The wildcard "*"
  * means all attributes, and a wildcard like "fs:*" means all attributes in the fs
  * namespace. The standard namespace for filesystem attributes is "fs".
  * Common attributes of interest are #G_FILE_ATTRIBUTE_FILESYSTEM_SIZE
@@ -1211,7 +1212,7 @@ g_file_query_info_finish (GFile         *file,
  * If the file does not exist, the G_IO_ERROR_NOT_FOUND error will be returned.
  * Other errors are possible too, and depend on what kind of filesystem the file is on.
  *
- * Returns: a #GFileInfo or %NULL if there was an error.
+ * Returns: (transfer full): a #GFileInfo or %NULL if there was an error.
  *     Free the returned object with g_object_unref().
  **/
 GFileInfo *
@@ -1292,7 +1293,7 @@ g_file_query_filesystem_info_async (GFile               *file,
  * Finishes an asynchronous filesystem info query.  See
  * g_file_query_filesystem_info_async().
  * 
- * Returns: #GFileInfo for given @file or %NULL on error.
+ * Returns: (transfer full): #GFileInfo for given @file or %NULL on error.
  *     Free the returned object with g_object_unref().
  **/
 GFileInfo *
@@ -1332,7 +1333,7 @@ g_file_query_filesystem_info_finish (GFile         *file,
  * triggering the cancellable object from another thread. If the operation
  * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 
  * 
- * Returns: a #GMount where the @file is located or %NULL on error.
+ * Returns: (transfer full): a #GMount where the @file is located or %NULL on error.
  *     Free the returned object with g_object_unref().
  **/
 GMount *
@@ -1406,7 +1407,7 @@ g_file_find_enclosing_mount_async (GFile              *file,
  * Finishes an asynchronous find mount request. 
  * See g_file_find_enclosing_mount_async().
  * 
- * Returns: #GMount for given @file or %NULL on error.
+ * Returns: (transfer full): #GMount for given @file or %NULL on error.
  *     Free the returned object with g_object_unref().
  **/
 GMount *
@@ -1448,7 +1449,8 @@ g_file_find_enclosing_mount_finish (GFile         *file,
  * If the file is a directory, the G_IO_ERROR_IS_DIRECTORY error will be returned.
  * Other errors are possible too, and depend on what kind of filesystem the file is on.
  *
- * Returns: #GFileInputStream or %NULL on error.
+ * Virtual: read_fn
+ * Returns: (transfer full): #GFileInputStream or %NULL on error.
  *     Free the returned object with g_object_unref().
  **/
 GFileInputStream *
@@ -1501,7 +1503,7 @@ g_file_read (GFile         *file,
  * returned. Other errors are possible too, and depend on what kind of
  * filesystem the file is on.
  * 
- * Returns: a #GFileOutputStream, or %NULL on error.
+ * Returns: (transfer full): a #GFileOutputStream, or %NULL on error.
  *     Free the returned object with g_object_unref().
  **/
 GFileOutputStream *
@@ -1557,7 +1559,7 @@ g_file_append_to (GFile             *file,
  * Other errors are possible too, and depend on what kind of
  * filesystem the file is on.
  * 
- * Returns: a #GFileOutputStream for the newly created file, or 
+ * Returns: (transfer full): a #GFileOutputStream for the newly created file, or 
  *     %NULL on error.
  *     Free the returned object with g_object_unref().
  **/
@@ -1590,7 +1592,7 @@ g_file_create (GFile             *file,
 /**
  * g_file_replace:
  * @file: input #GFile.
- * @etag: an optional <link linkend="gfile-etag">entity tag</link> for the 
+ * @etag: (allow-none): an optional <link linkend="gfile-etag">entity tag</link> for the 
  *     current #GFile, or #NULL to ignore.
  * @make_backup: %TRUE if a backup should be created.
  * @flags: a set of #GFileCreateFlags.
@@ -1639,7 +1641,7 @@ g_file_create (GFile             *file,
  * Other errors are possible too, and depend on what kind of
  * filesystem the file is on.
  *
- * Returns: a #GFileOutputStream or %NULL on error. 
+ * Returns: (transfer full): a #GFileOutputStream or %NULL on error. 
  *     Free the returned object with g_object_unref().
  **/
 GFileOutputStream *
@@ -1695,7 +1697,7 @@ g_file_replace (GFile             *file,
  * so make sure you really need to do read and write streaming, rather than
  * just opening for reading or writing.
  *
- * Returns: #GFileIOStream or %NULL on error.
+ * Returns: (transfer full): #GFileIOStream or %NULL on error.
  *     Free the returned object with g_object_unref().
  *
  * Since: 2.22
@@ -1754,7 +1756,7 @@ g_file_open_readwrite (GFile                      *file,
  * supported, so make sure you really need to do read and write streaming,
  * rather than just opening for reading or writing.
  *
- * Returns: a #GFileIOStream for the newly created file, or %NULL on error.
+ * Returns: (transfer full): a #GFileIOStream for the newly created file, or %NULL on error.
  *     Free the returned object with g_object_unref().
  *
  * Since: 2.22
@@ -1788,7 +1790,7 @@ g_file_create_readwrite (GFile             *file,
 /**
  * g_file_replace_readwrite:
  * @file: a #GFile
- * @etag: an optional <link linkend="gfile-etag">entity tag</link> for the
+ * @etag: (allow-none): an optional <link linkend="gfile-etag">entity tag</link> for the
  *     current #GFile, or #NULL to ignore
  * @make_backup: %TRUE if a backup should be created
  * @flags: a set of #GFileCreateFlags
@@ -1806,7 +1808,7 @@ g_file_create_readwrite (GFile             *file,
  * supported, so make sure you really need to do read and write streaming,
  * rather than just opening for reading or writing.
  *
- * Returns: a #GFileIOStream or %NULL on error.
+ * Returns: (transfer full): a #GFileIOStream or %NULL on error.
  *     Free the returned object with g_object_unref().
  *
  * Since: 2.22
@@ -1884,7 +1886,7 @@ g_file_read_async (GFile               *file,
  * Finishes an asynchronous file read operation started with 
  * g_file_read_async(). 
  *  
- * Returns: a #GFileInputStream or %NULL on error.
+ * Returns: (transfer full): a #GFileInputStream or %NULL on error.
  *     Free the returned object with g_object_unref().
  **/
 GFileInputStream *
@@ -1956,7 +1958,7 @@ g_file_append_to_async (GFile               *file,
  * Finishes an asynchronous file append operation started with 
  * g_file_append_to_async(). 
  * 
- * Returns: a valid #GFileOutputStream or %NULL on error.
+ * Returns: (transfer full): a valid #GFileOutputStream or %NULL on error.
  *     Free the returned object with g_object_unref().
  **/
 GFileOutputStream *
@@ -2029,7 +2031,7 @@ g_file_create_async (GFile               *file,
  * Finishes an asynchronous file create operation started with 
  * g_file_create_async(). 
  * 
- * Returns: a #GFileOutputStream or %NULL on error.
+ * Returns: (transfer full): a #GFileOutputStream or %NULL on error.
  *     Free the returned object with g_object_unref().
  **/
 GFileOutputStream *
@@ -2056,7 +2058,7 @@ g_file_create_finish (GFile         *file,
 /**
  * g_file_replace_async:
  * @file: input #GFile.
- * @etag: an <link linkend="gfile-etag">entity tag</link> for the 
+ * @etag: (allow-none): an <link linkend="gfile-etag">entity tag</link> for the 
  *     current #GFile, or NULL to ignore.
  * @make_backup: %TRUE if a backup should be created.
  * @flags: a set of #GFileCreateFlags.
@@ -2109,7 +2111,7 @@ g_file_replace_async (GFile               *file,
  * Finishes an asynchronous file replace operation started with 
  * g_file_replace_async(). 
  * 
- * Returns: a #GFileOutputStream, or %NULL on error.
+ * Returns: (transfer full): a #GFileOutputStream, or %NULL on error.
  *     Free the returned object with g_object_unref().
  **/
 GFileOutputStream *
@@ -2181,7 +2183,7 @@ g_file_open_readwrite_async (GFile                      *file,
  * Finishes an asynchronous file read operation started with
  * g_file_open_readwrite_async().
  *
- * Returns: a #GFileIOStream or %NULL on error.
+ * Returns: (transfer full): a #GFileIOStream or %NULL on error.
  *     Free the returned object with g_object_unref().
  *
  * Since: 2.22
@@ -2259,7 +2261,7 @@ g_file_create_readwrite_async (GFile               *file,
  * Finishes an asynchronous file create operation started with
  * g_file_create_readwrite_async().
  *
- * Returns: a #GFileIOStream or %NULL on error.
+ * Returns: (transfer full): a #GFileIOStream or %NULL on error.
  *     Free the returned object with g_object_unref().
  *
  * Since: 2.22
@@ -2288,7 +2290,7 @@ g_file_create_readwrite_finish (GFile         *file,
 /**
  * g_file_replace_readwrite_async:
  * @file: input #GFile.
- * @etag: an <link linkend="gfile-etag">entity tag</link> for the
+ * @etag: (allow-none): an <link linkend="gfile-etag">entity tag</link> for the
  *     current #GFile, or NULL to ignore.
  * @make_backup: %TRUE if a backup should be created.
  * @flags: a set of #GFileCreateFlags.
@@ -2343,7 +2345,7 @@ g_file_replace_readwrite_async (GFile               *file,
  * Finishes an asynchronous file replace operation started with
  * g_file_replace_readwrite_async().
  *
- * Returns: a #GFileIOStream, or %NULL on error.
+ * Returns: (transfer full): a #GFileIOStream, or %NULL on error.
  *     Free the returned object with g_object_unref().
  *
  * Since: 2.22
@@ -2456,7 +2458,8 @@ open_source_for_copy (GFile           *source,
       info = g_file_query_info (destination, G_FILE_ATTRIBUTE_STANDARD_TYPE,
                                G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
                                cancellable, &my_error);
-      if (info != NULL)
+      if (info != NULL &&
+          g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_STANDARD_TYPE))
        {
          file_type = g_file_info_get_file_type (info);
          g_object_unref (info);
@@ -2483,12 +2486,12 @@ open_source_for_copy (GFile           *source,
          /* Error getting info from target, return that error 
            * (except for NOT_FOUND, which is no error here) 
            */
-         if (my_error->domain != G_IO_ERROR && my_error->code != G_IO_ERROR_NOT_FOUND)
+         if (my_error != NULL && !g_error_matches (my_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
            {
              g_propagate_error (error, my_error);
              return NULL;
            }
-         g_error_free (my_error);
+         g_clear_error (&my_error);
        }
       
       g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_WOULD_RECURSE,
@@ -3445,19 +3448,20 @@ g_file_make_directory_with_parents (GFile         *file,
 
 /**
  * g_file_make_symbolic_link:
- * @file: input #GFile.
- * @symlink_value: a string with the value of the new symlink.
+ * @file: a #GFile with the name of the symlink to create
+ * @symlink_value: a string with the path for the target of the new symlink
  * @cancellable: optional #GCancellable object, %NULL to ignore.
- * @error: a #GError. 
- * 
- * Creates a symbolic link.
+ * @error: a #GError.
+ *
+ * Creates a symbolic link named @file which contains the string
+ * @symlink_value.
  *
  * If @cancellable is not %NULL, then the operation can be cancelled by
  * triggering the cancellable object from another thread. If the operation
- * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 
- * 
+ * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.
+ *
  * Returns: %TRUE on the creation of a new symlink, %FALSE otherwise.
- **/
+ */
 gboolean
 g_file_make_symbolic_link (GFile         *file,
                           const char    *symlink_value,
@@ -3505,7 +3509,8 @@ g_file_make_symbolic_link (GFile         *file,
  * If @cancellable is not %NULL, then the operation can be cancelled by
  * triggering the cancellable object from another thread. If the operation
  * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 
- * 
+ *
+ * Virtual: delete_file
  * Returns: %TRUE if the file was deleted. %FALSE otherwise.
  **/
 gboolean
@@ -3598,7 +3603,7 @@ g_file_trash (GFile         *file,
  * triggering the cancellable object from another thread. If the operation
  * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 
  * 
- * Returns: a #GFile specifying what @file was renamed to, or %NULL 
+ * Returns: (transfer full): a #GFile specifying what @file was renamed to, or %NULL 
  *     if there was an error.
  *     Free the returned object with g_object_unref().
  **/
@@ -3679,7 +3684,7 @@ g_file_set_display_name_async (GFile               *file,
  * Finishes setting a display name started with 
  * g_file_set_display_name_async().
  * 
- * Returns: a #GFile or %NULL on error.
+ * Returns: (transfer full): a #GFile or %NULL on error.
  *     Free the returned object with g_object_unref().
  **/
 GFile *
@@ -3998,7 +4003,7 @@ g_file_set_attributes_async (GFile               *file,
  * g_file_set_attributes_finish:
  * @file: input #GFile.
  * @result: a #GAsyncResult.
- * @info: a #GFileInfo.
+ * @info: (out) (transfer full): a #GFileInfo.
  * @error: a #GError, or %NULL
  * 
  * Finishes setting an attribute started in g_file_set_attributes_async().
@@ -4278,7 +4283,7 @@ g_file_mount_mountable (GFile               *file,
  * Finish an asynchronous mount operation that was started 
  * with g_file_mount_mountable().
  *
- * Returns: a #GFile or %NULL on error.
+ * Returns: (transfer full): a #GFile or %NULL on error.
  *     Free the returned object with g_object_unref().
  **/
 GFile *
@@ -4685,8 +4690,9 @@ g_file_eject_mountable_with_operation_finish (GFile         *file,
  * If @cancellable is not %NULL, then the operation can be cancelled by
  * triggering the cancellable object from another thread. If the operation
  * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 
- * 
- * Returns: a #GFileMonitor for the given @file, or %NULL on error.
+ *
+ * Virtual: monitor_dir
+ * Returns: (transfer full): a #GFileMonitor for the given @file, or %NULL on error.
  *     Free the returned object with g_object_unref().
  **/
 GFileMonitor*
@@ -4729,7 +4735,7 @@ g_file_monitor_directory (GFile             *file,
  * triggering the cancellable object from another thread. If the operation
  * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 
  * 
- * Returns: a #GFileMonitor for the given @file, or %NULL on error.
+ * Returns: (transfer full): a #GFileMonitor for the given @file, or %NULL on error.
  *     Free the returned object with g_object_unref().
  **/
 GFileMonitor*
@@ -4774,7 +4780,7 @@ g_file_monitor_file (GFile             *file,
  * triggering the cancellable object from another thread. If the operation
  * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 
  * 
- * Returns: a #GFileMonitor for the given @file, or %NULL on error.
+ * Returns: (transfer full): a #GFileMonitor for the given @file, or %NULL on error.
  *     Free the returned object with g_object_unref().
  *
  * Since: 2.18
@@ -4824,10 +4830,7 @@ query_info_async_thread (GSimpleAsyncResult *res,
   info = g_file_query_info (G_FILE (object), data->attributes, data->flags, cancellable, &error);
 
   if (info == NULL)
-    {
-      g_simple_async_result_set_from_error (res, error);
-      g_error_free (error);
-    }
+    g_simple_async_result_take_error (res, error);
   else
     data->info = info;
 }
@@ -4900,10 +4903,7 @@ query_filesystem_info_async_thread (GSimpleAsyncResult *res,
   info = g_file_query_filesystem_info (G_FILE (object), data->attributes, cancellable, &error);
 
   if (info == NULL)
-    {
-      g_simple_async_result_set_from_error (res, error);
-      g_error_free (error);
-    }
+    g_simple_async_result_take_error (res, error);
   else
     data->info = info;
 }
@@ -4975,10 +4975,7 @@ enumerate_children_async_thread (GSimpleAsyncResult *res,
   enumerator = g_file_enumerate_children (G_FILE (object), data->attributes, data->flags, cancellable, &error);
 
   if (enumerator == NULL)
-    {
-      g_simple_async_result_set_from_error (res, error);
-      g_error_free (error);
-    }
+    g_simple_async_result_take_error (res, error);
   else
     data->enumerator = enumerator;
 }
@@ -5040,8 +5037,7 @@ open_read_async_thread (GSimpleAsyncResult *res,
                            G_IO_ERROR_NOT_SUPPORTED,
                            _("Operation not supported"));
 
-      g_simple_async_result_set_from_error (res, error);
-      g_error_free (error);
+      g_simple_async_result_take_error (res, error);
 
       return;
     }
@@ -5049,10 +5045,7 @@ open_read_async_thread (GSimpleAsyncResult *res,
   stream = iface->read_fn (G_FILE (object), cancellable, &error);
 
   if (stream == NULL)
-    {
-      g_simple_async_result_set_from_error (res, error);
-      g_error_free (error);
-    }
+    g_simple_async_result_take_error (res, error);
   else
     g_simple_async_result_set_op_res_gpointer (res, stream, g_object_unref);
 }
@@ -5106,10 +5099,7 @@ append_to_async_thread (GSimpleAsyncResult *res,
   stream = iface->append_to (G_FILE (object), *data, cancellable, &error);
 
   if (stream == NULL)
-    {
-      g_simple_async_result_set_from_error (res, error);
-      g_error_free (error);
-    }
+    g_simple_async_result_take_error (res, error);
   else
     g_simple_async_result_set_op_res_gpointer (res, stream, g_object_unref);
 }
@@ -5169,10 +5159,7 @@ create_async_thread (GSimpleAsyncResult *res,
   stream = iface->create (G_FILE (object), *data, cancellable, &error);
 
   if (stream == NULL)
-    {
-      g_simple_async_result_set_from_error (res, error);
-      g_error_free (error);
-    }
+    g_simple_async_result_take_error (res, error);
   else
     g_simple_async_result_set_op_res_gpointer (res, stream, g_object_unref);
 }
@@ -5253,10 +5240,7 @@ replace_async_thread (GSimpleAsyncResult *res,
                           &error);
 
   if (stream == NULL)
-    {
-      g_simple_async_result_set_from_error (res, error);
-      g_error_free (error);
-    }
+    g_simple_async_result_take_error (res, error);
   else
     data->stream = stream;
 }
@@ -5320,8 +5304,7 @@ open_readwrite_async_thread (GSimpleAsyncResult *res,
                            G_IO_ERROR_NOT_SUPPORTED,
                            _("Operation not supported"));
 
-      g_simple_async_result_set_from_error (res, error);
-      g_error_free (error);
+      g_simple_async_result_take_error (res, error);
 
       return;
     }
@@ -5329,10 +5312,7 @@ open_readwrite_async_thread (GSimpleAsyncResult *res,
   stream = iface->open_readwrite (G_FILE (object), cancellable, &error);
 
   if (stream == NULL)
-    {
-      g_simple_async_result_set_from_error (res, error);
-      g_error_free (error);
-    }
+    g_simple_async_result_take_error (res, error);
   else
     g_simple_async_result_set_op_res_gpointer (res, stream, g_object_unref);
 }
@@ -5389,8 +5369,7 @@ create_readwrite_async_thread (GSimpleAsyncResult *res,
                            G_IO_ERROR_NOT_SUPPORTED,
                            _("Operation not supported"));
 
-      g_simple_async_result_set_from_error (res, error);
-      g_error_free (error);
+      g_simple_async_result_take_error (res, error);
 
       return;
     }
@@ -5398,10 +5377,7 @@ create_readwrite_async_thread (GSimpleAsyncResult *res,
   stream = iface->create_readwrite (G_FILE (object), *data, cancellable, &error);
 
   if (stream == NULL)
-    {
-      g_simple_async_result_set_from_error (res, error);
-      g_error_free (error);
-    }
+    g_simple_async_result_take_error (res, error);
   else
     g_simple_async_result_set_op_res_gpointer (res, stream, g_object_unref);
 }
@@ -5482,10 +5458,7 @@ replace_readwrite_async_thread (GSimpleAsyncResult *res,
                                     &error);
 
   if (stream == NULL)
-    {
-      g_simple_async_result_set_from_error (res, error);
-      g_error_free (error);
-    }
+    g_simple_async_result_take_error (res, error);
   else
     data->stream = stream;
 }
@@ -5560,10 +5533,7 @@ set_display_name_async_thread (GSimpleAsyncResult *res,
   file = g_file_set_display_name (G_FILE (object), data->name, cancellable, &error);
 
   if (file == NULL)
-    {
-      g_simple_async_result_set_from_error (res, error);
-      g_error_free (error);
-    }
+    g_simple_async_result_take_error (res, error);
   else
     data->file = file;
 }
@@ -5696,10 +5666,7 @@ find_enclosing_mount_async_thread (GSimpleAsyncResult *res,
   mount = g_file_find_enclosing_mount (G_FILE (object), cancellable, &error);
 
   if (mount == NULL)
-    {
-      g_simple_async_result_set_from_error (res, error);
-      g_error_free (error);
-    }
+    g_simple_async_result_take_error (res, error);
   else
     g_simple_async_result_set_op_res_gpointer (res, mount, (GDestroyNotify)g_object_unref);
 }
@@ -5828,10 +5795,7 @@ copy_async_thread (GIOSchedulerJob *job,
                                         NULL, NULL);
   
   if (!result)
-    {
-      g_simple_async_result_set_from_error (res, error);
-      g_error_free (error);
-    }
+    g_simple_async_result_take_error (res, error);
 
   g_simple_async_result_complete_in_idle (res);
 
@@ -5881,13 +5845,14 @@ g_file_real_copy_finish (GFile        *file,
 
 /**
  * g_file_new_for_path:
- * @path: a string containing a relative or absolute path.
+ * @path: a string containing a relative or absolute path. The string
+ *   must be encoded in the glib filename encoding.
  * 
  * Constructs a #GFile for a given path. This operation never
  * fails, but the returned object might not support any I/O
  * operation if @path is malformed.
  * 
- * Returns: a new #GFile for the given @path. 
+ * Returns: (transfer full): a new #GFile for the given @path. 
  **/
 GFile *
 g_file_new_for_path (const char *path)
@@ -5899,14 +5864,14 @@ g_file_new_for_path (const char *path)
  
 /**
  * g_file_new_for_uri:
- * @uri: a string containing a URI.
+ * @uri: a UTF8 string containing a URI.
  * 
  * Constructs a #GFile for a given URI. This operation never 
  * fails, but the returned object might not support any I/O 
  * operation if @uri is malformed or if the uri type is 
  * not supported.
  * 
- * Returns: a #GFile for the given @uri.
+ * Returns: (transfer full): a #GFile for the given @uri.
  **/ 
 GFile *
 g_file_new_for_uri (const char *uri)
@@ -5924,7 +5889,7 @@ g_file_new_for_uri (const char *uri)
  * This operation never fails, but the returned object might not support any I/O
  * operation if the @parse_name cannot be parsed.
  * 
- * Returns: a new #GFile.
+ * Returns: (transfer full): a new #GFile.
  **/
 GFile *
 g_file_parse_name (const char *parse_name)
@@ -5970,7 +5935,7 @@ has_valid_scheme (const char *uri)
  * This operation never fails, but the returned object might not support any
  * I/O operation if @arg points to a malformed path.
  *
- * Returns: a new #GFile. 
+ * Returns: (transfer full): a new #GFile. 
  **/
 GFile *
 g_file_new_for_commandline_arg (const char *arg)
@@ -6095,7 +6060,7 @@ g_file_mount_enclosing_volume_finish (GFile         *location,
  * triggering the cancellable object from another thread. If the operation
  * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 
  *
- * Returns: a #GAppInfo if the handle was found, %NULL if there were errors.
+ * Returns: (transfer full): a #GAppInfo if the handle was found, %NULL if there were errors.
  * When you are done with it, release it with g_object_unref()
  **/
 GAppInfo *
@@ -6158,10 +6123,10 @@ g_file_query_default_handler (GFile                  *file,
  * g_file_load_contents:
  * @file: input #GFile.
  * @cancellable: optional #GCancellable object, %NULL to ignore.
- * @contents: a location to place the contents of the file.
- * @length: a location to place the length of the contents of the file,
+ * @contents: (out) (transfer full): a location to place the contents of the file.
+ * @length: (out) (allow-none): a location to place the length of the contents of the file,
  *    or %NULL if the length is not needed
- * @etag_out: a location to place the current entity tag for the file,
+ * @etag_out: (out) (allow-none): a location to place the current entity tag for the file,
  *    or %NULL if the entity tag is not needed
  * @error: a #GError, or %NULL
  *
@@ -6403,12 +6368,11 @@ load_contents_open_callback (GObject      *obj,
     }
   else
     {
-      res = g_simple_async_result_new_from_error (G_OBJECT (data->file),
+      res = g_simple_async_result_new_take_error (G_OBJECT (data->file),
                                                  data->callback,
                                                  data->user_data,
                                                  error);
       g_simple_async_result_complete (res);
-      g_error_free (error);
       load_contents_data_free (data);
       g_object_unref (res);
     }
@@ -6466,10 +6430,10 @@ g_file_load_partial_contents_async (GFile                 *file,
  * g_file_load_partial_contents_finish:
  * @file: input #GFile.
  * @res: a #GAsyncResult. 
- * @contents: a location to place the contents of the file.
- * @length: a location to place the length of the contents of the file,
+ * @contents: (out) (transfer full): a location to place the contents of the file.
+ * @length: (out) (allow-none): a location to place the length of the contents of the file,
  *     or %NULL if the length is not needed
- * @etag_out: a location to place the current entity tag for the file,
+ * @etag_out: (out) (allow-none): a location to place the current entity tag for the file,
  *     or %NULL if the entity tag is not needed
  * @error: a #GError, or %NULL
  * 
@@ -6572,10 +6536,10 @@ g_file_load_contents_async (GFile               *file,
  * g_file_load_contents_finish:
  * @file: input #GFile.
  * @res: a #GAsyncResult. 
- * @contents: a location to place the contents of the file.
- * @length: a location to place the length of the contents of the file,
+ * @contents: (out) (transfer full): a location to place the contents of the file.
+ * @length: (out) (allow-none): a location to place the length of the contents of the file,
  *     or %NULL if the length is not needed
- * @etag_out: a location to place the current entity tag for the file,
+ * @etag_out: (out) (allow-none): a location to place the current entity tag for the file,
  *     or %NULL if the entity tag is not needed
  * @error: a #GError, or %NULL
  * 
@@ -6609,11 +6573,11 @@ g_file_load_contents_finish (GFile         *file,
  * @file: input #GFile.
  * @contents: a string containing the new contents for @file.
  * @length: the length of @contents in bytes.
- * @etag: the old <link linkend="gfile-etag">entity tag</link> 
+ * @etag: (allow-none): the old <link linkend="gfile-etag">entity tag</link> 
  *     for the document, or %NULL
  * @make_backup: %TRUE if a backup should be created.
  * @flags: a set of #GFileCreateFlags.
- * @new_etag: a location to a new <link linkend="gfile-etag">entity tag</link>
+ * @new_etag: (allow-none) (out): a location to a new <link linkend="gfile-etag">entity tag</link>
  *      for the document. This should be freed with g_free() when no longer 
  *      needed, or %NULL
  * @cancellable: optional #GCancellable object, %NULL to ignore.
@@ -6807,12 +6771,11 @@ replace_contents_open_callback (GObject      *obj,
     }
   else
     {
-      res = g_simple_async_result_new_from_error (G_OBJECT (data->file),
+      res = g_simple_async_result_new_take_error (G_OBJECT (data->file),
                                                  data->callback,
                                                  data->user_data,
                                                  error);
       g_simple_async_result_complete (res);
-      g_error_free (error);
       replace_contents_data_free (data);
       g_object_unref (res);
     }
@@ -6823,7 +6786,7 @@ replace_contents_open_callback (GObject      *obj,
  * @file: input #GFile.
  * @contents: string of contents to replace the file with.
  * @length: the length of @contents in bytes.
- * @etag: a new <link linkend="gfile-etag">entity tag</link> for the @file, or %NULL
+ * @etag: (allow-none): a new <link linkend="gfile-etag">entity tag</link> for the @file, or %NULL
  * @make_backup: %TRUE if a backup should be created.
  * @flags: a set of #GFileCreateFlags.
  * @cancellable: optional #GCancellable object, %NULL to ignore.
@@ -6886,7 +6849,7 @@ g_file_replace_contents_async  (GFile               *file,
  * g_file_replace_contents_finish:
  * @file: input #GFile.
  * @res: a #GAsyncResult. 
- * @new_etag: a location of a new <link linkend="gfile-etag">entity tag</link> 
+ * @new_etag: (out) (allow-none): a location of a new <link linkend="gfile-etag">entity tag</link> 
  *     for the document. This should be freed with g_free() when it is no 
  *     longer needed, or %NULL
  * @error: a #GError, or %NULL 
@@ -7225,6 +7188,3 @@ g_file_supports_thread_contexts (GFile *file)
  iface = G_FILE_GET_IFACE (file);
  return iface->supports_thread_contexts;
 }
-
-#define __G_FILE_C__
-#include "gioaliasdef.c"