/* Returns: #TRUE on success or #FALSE on error.  */
gboolean g_file_enumerator_close(GFileEnumerator *enumerator, GCancellable *cancellable, GError **error)
/* Returns: #TRUE on success or #FALSE on error.  */
gboolean g_file_enumerator_close(GFileEnumerator *enumerator, GCancellable *cancellable, GError **error)
{
  GFileEnumeratorClass *class;
  g_return_val_if_fail (G_IS_FILE_ENUMERATOR (enumerator), FALSE);
  g_return_val_if_fail (enumerator != NULL, FALSE);
  class = G_FILE_ENUMERATOR_GET_CLASS (enumerator);
  if (enumerator->priv->closed)
    return TRUE;
  if (enumerator->priv->pending)
    {
      g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_PENDING,
                           _("File enumerator has outstanding operation"));
      return FALSE;
    }
  if (cancellable)
    g_cancellable_push_current (cancellable);
  enumerator->priv->pending = TRUE;
  (* class->close_fn) (enumerator, cancellable, error);
  enumerator->priv->pending = FALSE;
  enumerator->priv->closed = TRUE;
  if (cancellable)
    g_cancellable_pop_current (cancellable);
  return TRUE;
}