* @file1: the first #GFile
* @file2: the second #GFile
*
- * Checks equality of two given #GFiles.
+ * Checks if the two given #GFiles refer to the same file.
*
* Note that two #GFiles that differ can still refer to the same
* file on the filesystem due to various forms of filename
* This call does no blocking I/O.
*
* Returns: %TRUE if @file1 and @file2 are equal.
- * %FALSE if either is not a #GFile.
*/
gboolean
g_file_equal (GFile *file1,
g_return_val_if_fail (G_IS_FILE (file1), FALSE);
g_return_val_if_fail (G_IS_FILE (file2), FALSE);
+ if (file1 == file2)
+ return TRUE;
+
if (G_TYPE_FROM_INSTANCE (file1) != G_TYPE_FROM_INSTANCE (file2))
return FALSE;
* so a path like /foo is not considered a prefix of /foobar, only
* of /foo/bar.
*
+ * A #GFile is not a prefix of itself. If you want to check for
+ * equality, use g_file_equal().
+ *
* This call does no I/O, as it works purely on names. As such it can
* sometimes return %FALSE even if @file is inside a @prefix (from a
* filesystem point of view), because the prefix of @file is an alias
* operation was cancelled, the error %G_IO_ERROR_CANCELLED will be
* returned.
*
- * If you pass in a non-%NULL @etag value, then this value is
- * compared to the current entity tag of the file, and if they differ
- * an %G_IO_ERROR_WRONG_ETAG error is returned. This generally means
- * that the file has been changed since you last read it. You can get
- * the new etag from g_file_output_stream_get_etag() after you've
- * finished writing and closed the #GFileOutputStream. When you load
- * a new file you can use g_file_input_stream_query_info() to get
- * the etag of the file.
+ * If you pass in a non-%NULL @etag value and @file already exists, then
+ * this value is compared to the current entity tag of the file, and if
+ * they differ an %G_IO_ERROR_WRONG_ETAG error is returned. This
+ * generally means that the file has been changed since you last read
+ * it. You can get the new etag from g_file_output_stream_get_etag()
+ * after you've finished writing and closed the #GFileOutputStream. When
+ * you load a new file you can use g_file_input_stream_query_info() to
+ * get the etag of the file.
*
* If @make_backup is %TRUE, this function will attempt to make a
* backup of the current file before overwriting it. If this fails
g_propagate_error (error, my_error);
return FALSE;
}
+ else
+ g_clear_error (&my_error);
}
/* If the types are different, and the destination method failed
g_propagate_error (error, my_error);
return FALSE;
}
+ else
+ g_clear_error (&my_error);
}
}
{
MeasureTaskData *data = task_data;
GError *error = NULL;
- MeasureResult result;
+ MeasureResult result = { 0, };
if (g_file_measure_disk_usage (source_object, data->flags, cancellable,
data->progress_callback ? measure_disk_usage_progress : NULL, task,