/* directory.c generated by valac 0.36.12.13-3ae08, the Vala compiler
 * generated from directory.vala, do not modify */

/* This file is part of GNOME Games. License: GPL-3.0+.*/

#include <glib.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>


#define GAMES_TYPE_DIRECTORY (games_directory_get_type ())
#define GAMES_DIRECTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_DIRECTORY, GamesDirectory))
#define GAMES_DIRECTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_DIRECTORY, GamesDirectoryClass))
#define GAMES_IS_DIRECTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_DIRECTORY))
#define GAMES_IS_DIRECTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_DIRECTORY))
#define GAMES_DIRECTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_DIRECTORY, GamesDirectoryClass))

typedef struct _GamesDirectory GamesDirectory;
typedef struct _GamesDirectoryClass GamesDirectoryClass;
typedef struct _GamesDirectoryPrivate GamesDirectoryPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _GamesDirectory {
	GObject parent_instance;
	GamesDirectoryPrivate * priv;
};

struct _GamesDirectoryClass {
	GObjectClass parent_class;
};

struct _GamesDirectoryPrivate {
	GFile* file;
};

typedef gboolean (*GamesDirectoryFileInfoTest) (GFileInfo* file_info, void* user_data, GError** error);

static gpointer games_directory_parent_class = NULL;

GType games_directory_get_type (void) G_GNUC_CONST;
#define GAMES_DIRECTORY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GAMES_TYPE_DIRECTORY, GamesDirectoryPrivate))
enum  {
	GAMES_DIRECTORY_0_PROPERTY
};
GamesDirectory* games_directory_new (GFile* file);
GamesDirectory* games_directory_construct (GType object_type, GFile* file);
void games_directory_foreach (GamesDirectory* self, const gchar* attributes, GamesDirectoryFileInfoTest file_info_test, void* file_info_test_target, GError** error);
static void games_directory_finalize (GObject * obj);


static gpointer _g_object_ref0 (gpointer self) {
	return self ? g_object_ref (self) : NULL;
}


GamesDirectory* games_directory_construct (GType object_type, GFile* file) {
	GamesDirectory * self = NULL;
	GFile* _tmp0_;
	GFile* _tmp1_;
	g_return_val_if_fail (file != NULL, NULL);
	self = (GamesDirectory*) g_object_new (object_type, NULL);
	_tmp0_ = file;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (self->priv->file);
	self->priv->file = _tmp1_;
	return self;
}


GamesDirectory* games_directory_new (GFile* file) {
	return games_directory_construct (GAMES_TYPE_DIRECTORY, file);
}


void games_directory_foreach (GamesDirectory* self, const gchar* attributes, GamesDirectoryFileInfoTest file_info_test, void* file_info_test_target, GError** error) {
	GFileEnumerator* enumerator = NULL;
	GFile* _tmp0_;
	const gchar* _tmp1_;
	GFileEnumerator* _tmp2_;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (attributes != NULL);
	_tmp0_ = self->priv->file;
	_tmp1_ = attributes;
	_tmp2_ = g_file_enumerate_children (_tmp0_, _tmp1_, G_FILE_QUERY_INFO_NONE, NULL, &_inner_error_);
	enumerator = _tmp2_;
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_propagate_error (error, _inner_error_);
		return;
	}
	{
		GFileInfo* file_info = NULL;
		GFileEnumerator* _tmp3_;
		GFileInfo* _tmp4_;
		_tmp3_ = enumerator;
		_tmp4_ = g_file_enumerator_next_file (_tmp3_, NULL, &_inner_error_);
		file_info = _tmp4_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			g_propagate_error (error, _inner_error_);
			_g_object_unref0 (enumerator);
			return;
		}
		{
			gboolean _tmp5_ = FALSE;
			_tmp5_ = TRUE;
			while (TRUE) {
				GFileInfo* _tmp10_;
				gboolean _tmp11_ = FALSE;
				GamesDirectoryFileInfoTest _tmp12_;
				void* _tmp12__target;
				GFileInfo* _tmp13_;
				gboolean _tmp14_;
				if (!_tmp5_) {
					GFileInfo* _tmp6_ = NULL;
					GFileEnumerator* _tmp7_;
					GFileInfo* _tmp8_;
					GFileInfo* _tmp9_;
					_tmp7_ = enumerator;
					_tmp8_ = g_file_enumerator_next_file (_tmp7_, NULL, &_inner_error_);
					_tmp6_ = _tmp8_;
					if (G_UNLIKELY (_inner_error_ != NULL)) {
						g_propagate_error (error, _inner_error_);
						_g_object_unref0 (file_info);
						_g_object_unref0 (enumerator);
						return;
					}
					_tmp9_ = _tmp6_;
					_tmp6_ = NULL;
					_g_object_unref0 (file_info);
					file_info = _tmp9_;
					_g_object_unref0 (_tmp6_);
				}
				_tmp5_ = FALSE;
				_tmp10_ = file_info;
				if (!(_tmp10_ != NULL)) {
					break;
				}
				_tmp12_ = file_info_test;
				_tmp12__target = file_info_test_target;
				_tmp13_ = file_info;
				_tmp14_ = _tmp12_ (_tmp13_, _tmp12__target, &_inner_error_);
				_tmp11_ = _tmp14_;
				if (G_UNLIKELY (_inner_error_ != NULL)) {
					g_propagate_error (error, _inner_error_);
					_g_object_unref0 (file_info);
					_g_object_unref0 (enumerator);
					return;
				}
				if (_tmp11_) {
					_g_object_unref0 (file_info);
					_g_object_unref0 (enumerator);
					return;
				}
			}
		}
		_g_object_unref0 (file_info);
	}
	_g_object_unref0 (enumerator);
}


static void games_directory_class_init (GamesDirectoryClass * klass) {
	games_directory_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (GamesDirectoryPrivate));
	G_OBJECT_CLASS (klass)->finalize = games_directory_finalize;
}


static void games_directory_instance_init (GamesDirectory * self) {
	self->priv = GAMES_DIRECTORY_GET_PRIVATE (self);
}


static void games_directory_finalize (GObject * obj) {
	GamesDirectory * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_DIRECTORY, GamesDirectory);
	_g_object_unref0 (self->priv->file);
	G_OBJECT_CLASS (games_directory_parent_class)->finalize (obj);
}


GType games_directory_get_type (void) {
	static volatile gsize games_directory_type_id__volatile = 0;
	if (g_once_init_enter (&games_directory_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (GamesDirectoryClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_directory_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesDirectory), 0, (GInstanceInitFunc) games_directory_instance_init, NULL };
		GType games_directory_type_id;
		games_directory_type_id = g_type_register_static (G_TYPE_OBJECT, "GamesDirectory", &g_define_type_info, 0);
		g_once_init_leave (&games_directory_type_id__volatile, games_directory_type_id);
	}
	return games_directory_type_id__volatile;
}



