/* local-cover.c generated by valac 0.36.12.13-3ae08, the Vala compiler
 * generated from local-cover.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>
#include <glib/gstdio.h>


#define GAMES_TYPE_COVER (games_cover_get_type ())
#define GAMES_COVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_COVER, GamesCover))
#define GAMES_IS_COVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_COVER))
#define GAMES_COVER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GAMES_TYPE_COVER, GamesCoverIface))

typedef struct _GamesCover GamesCover;
typedef struct _GamesCoverIface GamesCoverIface;

#define GAMES_TYPE_LOCAL_COVER (games_local_cover_get_type ())
#define GAMES_LOCAL_COVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_LOCAL_COVER, GamesLocalCover))
#define GAMES_LOCAL_COVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_LOCAL_COVER, GamesLocalCoverClass))
#define GAMES_IS_LOCAL_COVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_LOCAL_COVER))
#define GAMES_IS_LOCAL_COVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_LOCAL_COVER))
#define GAMES_LOCAL_COVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_LOCAL_COVER, GamesLocalCoverClass))

typedef struct _GamesLocalCover GamesLocalCover;
typedef struct _GamesLocalCoverClass GamesLocalCoverClass;
typedef struct _GamesLocalCoverPrivate GamesLocalCoverPrivate;

#define GAMES_TYPE_URI (games_uri_get_type ())
#define GAMES_URI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_URI, GamesUri))
#define GAMES_URI_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_URI, GamesUriClass))
#define GAMES_IS_URI(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_URI))
#define GAMES_IS_URI_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_URI))
#define GAMES_URI_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_URI, GamesUriClass))

typedef struct _GamesUri GamesUri;
typedef struct _GamesUriClass GamesUriClass;
#define _games_uri_unref0(var) ((var == NULL) ? NULL : (var = (games_uri_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _Block11Data Block11Data;

#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 _Block12Data Block12Data;

struct _GamesCoverIface {
	GTypeInterface parent_iface;
	GIcon* (*get_cover) (GamesCover* self);
};

struct _GamesLocalCover {
	GObject parent_instance;
	GamesLocalCoverPrivate * priv;
};

struct _GamesLocalCoverClass {
	GObjectClass parent_class;
};

struct _GamesLocalCoverPrivate {
	GamesUri* uri;
	gboolean resolved;
	GIcon* icon;
};

struct _Block11Data {
	int _ref_count_;
	GamesLocalCover* self;
	GFile* parent;
	gchar* basename;
	gchar* prefix;
	gchar* cover_path;
};

typedef gboolean (*GamesDirectoryFileInfoTest) (GFileInfo* file_info, void* user_data, GError** error);
struct _Block12Data {
	int _ref_count_;
	GamesLocalCover* self;
	GFile* parent;
	gchar* cover_path;
};


static gpointer games_local_cover_parent_class = NULL;
static GamesCoverIface * games_local_cover_games_cover_parent_iface = NULL;

GType games_cover_get_type (void) G_GNUC_CONST;
GType games_local_cover_get_type (void) G_GNUC_CONST;
gpointer games_uri_ref (gpointer instance);
void games_uri_unref (gpointer instance);
GParamSpec* games_param_spec_uri (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void games_value_set_uri (GValue* value, gpointer v_object);
void games_value_take_uri (GValue* value, gpointer v_object);
gpointer games_value_get_uri (const GValue* value);
GType games_uri_get_type (void) G_GNUC_CONST;
#define GAMES_LOCAL_COVER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GAMES_TYPE_LOCAL_COVER, GamesLocalCoverPrivate))
enum  {
	GAMES_LOCAL_COVER_0_PROPERTY
};
GamesLocalCover* games_local_cover_new (GamesUri* uri);
GamesLocalCover* games_local_cover_construct (GType object_type, GamesUri* uri);
static GIcon* games_local_cover_real_get_cover (GamesCover* base);
static gchar* games_local_cover_get_cover_path (GamesLocalCover* self, GError** error);
static gchar* games_local_cover_get_sibbling_cover_path (GamesLocalCover* self, GError** error);
static gchar* games_local_cover_get_directory_cover_path (GamesLocalCover* self, GError** error);
static Block11Data* block11_data_ref (Block11Data* _data11_);
static void block11_data_unref (void * _userdata_);
GFile* games_uri_to_file (GamesUri* self);
GType games_directory_get_type (void) G_GNUC_CONST;
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 gboolean __lambda16_ (Block11Data* _data11_, GFileInfo* sibbling, GError** error);
static gboolean ___lambda16__games_directory_file_info_test (GFileInfo* file_info, gpointer self, GError** error);
static Block12Data* block12_data_ref (Block12Data* _data12_);
static void block12_data_unref (void * _userdata_);
static gboolean __lambda17_ (Block12Data* _data12_, GFileInfo* sibbling, GError** error);
static gboolean ___lambda17__games_directory_file_info_test (GFileInfo* file_info, gpointer self, GError** error);
static void games_local_cover_finalize (GObject * obj);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
static gint _vala_array_length (gpointer array);


static gpointer _games_uri_ref0 (gpointer self) {
	return self ? games_uri_ref (self) : NULL;
}


GamesLocalCover* games_local_cover_construct (GType object_type, GamesUri* uri) {
	GamesLocalCover * self = NULL;
	GamesUri* _tmp0_;
	GamesUri* _tmp1_;
	g_return_val_if_fail (uri != NULL, NULL);
	self = (GamesLocalCover*) g_object_new (object_type, NULL);
	_tmp0_ = uri;
	_tmp1_ = _games_uri_ref0 (_tmp0_);
	_games_uri_unref0 (self->priv->uri);
	self->priv->uri = _tmp1_;
	return self;
}


GamesLocalCover* games_local_cover_new (GamesUri* uri) {
	return games_local_cover_construct (GAMES_TYPE_LOCAL_COVER, uri);
}


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


static GIcon* games_local_cover_real_get_cover (GamesCover* base) {
	GamesLocalCover * self;
	GIcon* result = NULL;
	gboolean _tmp0_;
	gchar* cover_path = NULL;
	const gchar* _tmp8_;
	GFile* file = NULL;
	const gchar* _tmp9_;
	GFile* _tmp10_;
	GFile* _tmp11_;
	GFileIcon* _tmp12_;
	GIcon* _tmp13_;
	GIcon* _tmp14_;
	GError * _inner_error_ = NULL;
	self = (GamesLocalCover*) base;
	_tmp0_ = self->priv->resolved;
	if (_tmp0_) {
		GIcon* _tmp1_;
		GIcon* _tmp2_;
		_tmp1_ = self->priv->icon;
		_tmp2_ = _g_object_ref0 (_tmp1_);
		result = _tmp2_;
		return result;
	}
	self->priv->resolved = TRUE;
	{
		gchar* _tmp3_ = NULL;
		gchar* _tmp4_;
		gchar* _tmp5_;
		_tmp4_ = games_local_cover_get_cover_path (self, &_inner_error_);
		_tmp3_ = _tmp4_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch42_g_error;
		}
		_tmp5_ = _tmp3_;
		_tmp3_ = NULL;
		_g_free0 (cover_path);
		cover_path = _tmp5_;
		_g_free0 (_tmp3_);
	}
	goto __finally42;
	__catch42_g_error:
	{
		GError* e = NULL;
		GError* _tmp6_;
		const gchar* _tmp7_;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp6_ = e;
		_tmp7_ = _tmp6_->message;
		g_debug ("local-cover.vala:23: %s", _tmp7_);
		result = NULL;
		_g_error_free0 (e);
		_g_free0 (cover_path);
		return result;
	}
	__finally42:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		_g_free0 (cover_path);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return NULL;
	}
	_tmp8_ = cover_path;
	if (_tmp8_ == NULL) {
		result = NULL;
		_g_free0 (cover_path);
		return result;
	}
	_tmp9_ = cover_path;
	_tmp10_ = g_file_new_for_path (_tmp9_);
	file = _tmp10_;
	_tmp11_ = file;
	_tmp12_ = (GFileIcon*) g_file_icon_new (_tmp11_);
	_g_object_unref0 (self->priv->icon);
	self->priv->icon = (GIcon*) _tmp12_;
	_tmp13_ = self->priv->icon;
	_tmp14_ = _g_object_ref0 (_tmp13_);
	result = _tmp14_;
	_g_object_unref0 (file);
	_g_free0 (cover_path);
	return result;
}


static gchar* games_local_cover_get_cover_path (GamesLocalCover* self, GError** error) {
	gchar* result = NULL;
	gchar* cover_path = NULL;
	gchar* _tmp0_;
	gboolean _tmp1_ = FALSE;
	const gchar* _tmp2_;
	gchar* _tmp5_ = NULL;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gboolean _tmp8_ = FALSE;
	const gchar* _tmp9_;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = games_local_cover_get_sibbling_cover_path (self, &_inner_error_);
	cover_path = _tmp0_;
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_propagate_error (error, _inner_error_);
		return NULL;
	}
	_tmp2_ = cover_path;
	if (_tmp2_ != NULL) {
		const gchar* _tmp3_;
		gboolean _tmp4_;
		_tmp3_ = cover_path;
		_tmp4_ = g_file_test (_tmp3_, G_FILE_TEST_EXISTS);
		_tmp1_ = _tmp4_;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		result = cover_path;
		return result;
	}
	_tmp6_ = games_local_cover_get_directory_cover_path (self, &_inner_error_);
	_tmp5_ = _tmp6_;
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_propagate_error (error, _inner_error_);
		_g_free0 (cover_path);
		return NULL;
	}
	_tmp7_ = _tmp5_;
	_tmp5_ = NULL;
	_g_free0 (cover_path);
	cover_path = _tmp7_;
	_tmp9_ = cover_path;
	if (_tmp9_ != NULL) {
		const gchar* _tmp10_;
		gboolean _tmp11_;
		_tmp10_ = cover_path;
		_tmp11_ = g_file_test (_tmp10_, G_FILE_TEST_EXISTS);
		_tmp8_ = _tmp11_;
	} else {
		_tmp8_ = FALSE;
	}
	if (_tmp8_) {
		result = cover_path;
		_g_free0 (_tmp5_);
		return result;
	}
	result = NULL;
	_g_free0 (_tmp5_);
	_g_free0 (cover_path);
	return result;
}


static Block11Data* block11_data_ref (Block11Data* _data11_) {
	g_atomic_int_inc (&_data11_->_ref_count_);
	return _data11_;
}


static void block11_data_unref (void * _userdata_) {
	Block11Data* _data11_;
	_data11_ = (Block11Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data11_->_ref_count_)) {
		GamesLocalCover* self;
		self = _data11_->self;
		_g_free0 (_data11_->cover_path);
		_g_free0 (_data11_->prefix);
		_g_free0 (_data11_->basename);
		_g_object_unref0 (_data11_->parent);
		_g_object_unref0 (self);
		g_slice_free (Block11Data, _data11_);
	}
}


static gchar* _vala_g_strjoinv (const gchar* separator, gchar** str_array, int str_array_length1) {
	gchar* result = NULL;
	const gchar* _tmp0_;
	gboolean _tmp1_ = FALSE;
	gchar** _tmp2_;
	gint _tmp2__length1;
	_tmp0_ = separator;
	if (_tmp0_ == NULL) {
		separator = "";
	}
	_tmp2_ = str_array;
	_tmp2__length1 = str_array_length1;
	if (_tmp2_ != NULL) {
		gboolean _tmp3_ = FALSE;
		gchar** _tmp4_;
		gint _tmp4__length1;
		_tmp4_ = str_array;
		_tmp4__length1 = str_array_length1;
		if (_tmp4__length1 > 0) {
			_tmp3_ = TRUE;
		} else {
			gboolean _tmp5_ = FALSE;
			gchar** _tmp6_;
			gint _tmp6__length1;
			_tmp6_ = str_array;
			_tmp6__length1 = str_array_length1;
			if (_tmp6__length1 == -1) {
				gchar** _tmp7_;
				gint _tmp7__length1;
				const gchar* _tmp8_;
				_tmp7_ = str_array;
				_tmp7__length1 = str_array_length1;
				_tmp8_ = _tmp7_[0];
				_tmp5_ = _tmp8_ != NULL;
			} else {
				_tmp5_ = FALSE;
			}
			_tmp3_ = _tmp5_;
		}
		_tmp1_ = _tmp3_;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		gint i = 0;
		gsize len = 0UL;
		gint _tmp31_;
		gint _tmp33_;
		gint _tmp34_;
		gsize _tmp35_;
		const gchar* _tmp36_;
		gint _tmp37_;
		gint _tmp38_;
		gint _tmp39_;
		const gchar* res = NULL;
		gsize _tmp40_;
		void* _tmp41_;
		void* ptr = NULL;
		const gchar* _tmp42_;
		gchar** _tmp43_;
		gint _tmp43__length1;
		const gchar* _tmp44_;
		void* _tmp45_;
		const gchar* _tmp62_;
		len = (gsize) 1;
		{
			gboolean _tmp9_ = FALSE;
			i = 0;
			_tmp9_ = TRUE;
			while (TRUE) {
				gboolean _tmp11_ = FALSE;
				gboolean _tmp12_ = FALSE;
				gchar** _tmp13_;
				gint _tmp13__length1;
				gint _tmp21_ = 0;
				gchar** _tmp22_;
				gint _tmp22__length1;
				gint _tmp23_;
				const gchar* _tmp24_;
				gsize _tmp30_;
				if (!_tmp9_) {
					gint _tmp10_;
					_tmp10_ = i;
					i = _tmp10_ + 1;
				}
				_tmp9_ = FALSE;
				_tmp13_ = str_array;
				_tmp13__length1 = str_array_length1;
				if (_tmp13__length1 != -1) {
					gint _tmp14_;
					gchar** _tmp15_;
					gint _tmp15__length1;
					_tmp14_ = i;
					_tmp15_ = str_array;
					_tmp15__length1 = str_array_length1;
					_tmp12_ = _tmp14_ < _tmp15__length1;
				} else {
					_tmp12_ = FALSE;
				}
				if (_tmp12_) {
					_tmp11_ = TRUE;
				} else {
					gboolean _tmp16_ = FALSE;
					gchar** _tmp17_;
					gint _tmp17__length1;
					_tmp17_ = str_array;
					_tmp17__length1 = str_array_length1;
					if (_tmp17__length1 == -1) {
						gchar** _tmp18_;
						gint _tmp18__length1;
						gint _tmp19_;
						const gchar* _tmp20_;
						_tmp18_ = str_array;
						_tmp18__length1 = str_array_length1;
						_tmp19_ = i;
						_tmp20_ = _tmp18_[_tmp19_];
						_tmp16_ = _tmp20_ != NULL;
					} else {
						_tmp16_ = FALSE;
					}
					_tmp11_ = _tmp16_;
				}
				if (!_tmp11_) {
					break;
				}
				_tmp22_ = str_array;
				_tmp22__length1 = str_array_length1;
				_tmp23_ = i;
				_tmp24_ = _tmp22_[_tmp23_];
				if (_tmp24_ != NULL) {
					gchar** _tmp25_;
					gint _tmp25__length1;
					gint _tmp26_;
					const gchar* _tmp27_;
					gint _tmp28_;
					gint _tmp29_;
					_tmp25_ = str_array;
					_tmp25__length1 = str_array_length1;
					_tmp26_ = i;
					_tmp27_ = _tmp25_[_tmp26_];
					_tmp28_ = strlen ((const gchar*) _tmp27_);
					_tmp29_ = _tmp28_;
					_tmp21_ = _tmp29_;
				} else {
					_tmp21_ = 0;
				}
				_tmp30_ = len;
				len = _tmp30_ + _tmp21_;
			}
		}
		_tmp31_ = i;
		if (_tmp31_ == 0) {
			gchar* _tmp32_;
			_tmp32_ = g_strdup ("");
			result = _tmp32_;
			return result;
		}
		_tmp33_ = i;
		str_array_length1 = _tmp33_;
		_tmp34_ = str_array_length1;
		_tmp35_ = len;
		_tmp36_ = separator;
		_tmp37_ = strlen ((const gchar*) _tmp36_);
		_tmp38_ = _tmp37_;
		_tmp39_ = i;
		len = _tmp35_ + (_tmp38_ * (_tmp39_ - 1));
		_tmp40_ = len;
		_tmp41_ = g_malloc (_tmp40_);
		res = _tmp41_;
		_tmp42_ = res;
		_tmp43_ = str_array;
		_tmp43__length1 = str_array_length1;
		_tmp44_ = _tmp43_[0];
		_tmp45_ = g_stpcpy ((void*) _tmp42_, (const gchar*) _tmp44_);
		ptr = _tmp45_;
		{
			gboolean _tmp46_ = FALSE;
			i = 1;
			_tmp46_ = TRUE;
			while (TRUE) {
				gint _tmp48_;
				gchar** _tmp49_;
				gint _tmp49__length1;
				void* _tmp50_;
				const gchar* _tmp51_;
				void* _tmp52_;
				const gchar* _tmp53_ = NULL;
				gchar** _tmp54_;
				gint _tmp54__length1;
				gint _tmp55_;
				const gchar* _tmp56_;
				void* _tmp60_;
				void* _tmp61_;
				if (!_tmp46_) {
					gint _tmp47_;
					_tmp47_ = i;
					i = _tmp47_ + 1;
				}
				_tmp46_ = FALSE;
				_tmp48_ = i;
				_tmp49_ = str_array;
				_tmp49__length1 = str_array_length1;
				if (!(_tmp48_ < _tmp49__length1)) {
					break;
				}
				_tmp50_ = ptr;
				_tmp51_ = separator;
				_tmp52_ = g_stpcpy (_tmp50_, (const gchar*) _tmp51_);
				ptr = _tmp52_;
				_tmp54_ = str_array;
				_tmp54__length1 = str_array_length1;
				_tmp55_ = i;
				_tmp56_ = _tmp54_[_tmp55_];
				if (_tmp56_ != NULL) {
					gchar** _tmp57_;
					gint _tmp57__length1;
					gint _tmp58_;
					const gchar* _tmp59_;
					_tmp57_ = str_array;
					_tmp57__length1 = str_array_length1;
					_tmp58_ = i;
					_tmp59_ = _tmp57_[_tmp58_];
					_tmp53_ = (const gchar*) _tmp59_;
				} else {
					_tmp53_ = "";
				}
				_tmp60_ = ptr;
				_tmp61_ = g_stpcpy (_tmp60_, _tmp53_);
				ptr = _tmp61_;
			}
		}
		_tmp62_ = res;
		res = NULL;
		result = (gchar*) _tmp62_;
		return result;
	} else {
		gchar* _tmp63_;
		_tmp63_ = g_strdup ("");
		result = _tmp63_;
		return result;
	}
}


static gboolean __lambda16_ (Block11Data* _data11_, GFileInfo* sibbling, GError** error) {
	GamesLocalCover* self;
	gboolean result = FALSE;
	gchar* sibbling_basename = NULL;
	GFileInfo* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	gboolean _tmp7_;
	gchar* type = NULL;
	GFileInfo* _tmp8_;
	const gchar* _tmp9_;
	gchar* _tmp10_;
	const gchar* _tmp11_;
	gboolean _tmp12_;
	GFile* sibbling_file = NULL;
	GFile* _tmp13_;
	const gchar* _tmp14_;
	GFile* _tmp15_;
	GFile* _tmp16_;
	gchar* _tmp17_;
	self = _data11_->self;
	g_return_val_if_fail (sibbling != NULL, FALSE);
	_tmp0_ = sibbling;
	_tmp1_ = g_file_info_get_name (_tmp0_);
	_tmp2_ = g_strdup (_tmp1_);
	sibbling_basename = _tmp2_;
	_tmp3_ = sibbling_basename;
	_tmp4_ = _data11_->basename;
	if (g_strcmp0 (_tmp3_, _tmp4_) == 0) {
		result = FALSE;
		_g_free0 (sibbling_basename);
		return result;
	}
	_tmp5_ = sibbling_basename;
	_tmp6_ = _data11_->prefix;
	_tmp7_ = g_str_has_prefix (_tmp5_, _tmp6_);
	if (!_tmp7_) {
		result = FALSE;
		_g_free0 (sibbling_basename);
		return result;
	}
	_tmp8_ = sibbling;
	_tmp9_ = g_file_info_get_content_type (_tmp8_);
	_tmp10_ = g_strdup (_tmp9_);
	type = _tmp10_;
	_tmp11_ = type;
	_tmp12_ = g_str_has_prefix (_tmp11_, "image");
	if (!_tmp12_) {
		result = FALSE;
		_g_free0 (type);
		_g_free0 (sibbling_basename);
		return result;
	}
	_tmp13_ = _data11_->parent;
	_tmp14_ = sibbling_basename;
	_tmp15_ = g_file_get_child (_tmp13_, _tmp14_);
	sibbling_file = _tmp15_;
	_tmp16_ = sibbling_file;
	_tmp17_ = g_file_get_path (_tmp16_);
	_g_free0 (_data11_->cover_path);
	_data11_->cover_path = _tmp17_;
	result = TRUE;
	_g_object_unref0 (sibbling_file);
	_g_free0 (type);
	_g_free0 (sibbling_basename);
	return result;
}


static gboolean ___lambda16__games_directory_file_info_test (GFileInfo* file_info, gpointer self, GError** error) {
	gboolean result;
	result = __lambda16_ (self, file_info, error);
	return result;
}


static gchar* games_local_cover_get_sibbling_cover_path (GamesLocalCover* self, GError** error) {
	gchar* result = NULL;
	Block11Data* _data11_;
	GFile* file = NULL;
	GamesUri* _tmp0_;
	GFile* _tmp1_;
	GFile* _tmp2_;
	GFile* _tmp3_;
	GFile* _tmp4_;
	GFile* _tmp5_;
	gchar* _tmp6_;
	gchar** splitted_basename = NULL;
	const gchar* _tmp7_;
	gchar** _tmp8_;
	gchar** _tmp9_;
	gint splitted_basename_length1;
	gint _splitted_basename_size_;
	gchar* _tmp10_ = NULL;
	gchar** _tmp11_;
	gint _tmp11__length1;
	gchar* _tmp17_;
	GamesDirectory* directory = NULL;
	GFile* _tmp18_;
	GamesDirectory* _tmp19_;
	GamesDirectory* _tmp20_;
	const gchar* _tmp21_;
	gchar* _tmp22_;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_data11_ = g_slice_new0 (Block11Data);
	_data11_->_ref_count_ = 1;
	_data11_->self = g_object_ref (self);
	_tmp0_ = self->priv->uri;
	_tmp1_ = games_uri_to_file (_tmp0_);
	file = _tmp1_;
	_tmp2_ = file;
	_tmp3_ = g_file_get_parent (_tmp2_);
	_data11_->parent = _tmp3_;
	_tmp4_ = _data11_->parent;
	if (_tmp4_ == NULL) {
		result = NULL;
		_g_object_unref0 (file);
		block11_data_unref (_data11_);
		_data11_ = NULL;
		return result;
	}
	_tmp5_ = file;
	_tmp6_ = g_file_get_basename (_tmp5_);
	_data11_->basename = _tmp6_;
	_tmp7_ = _data11_->basename;
	_tmp9_ = _tmp8_ = g_strsplit (_tmp7_, ".", 0);
	splitted_basename = _tmp9_;
	splitted_basename_length1 = _vala_array_length (_tmp8_);
	_splitted_basename_size_ = splitted_basename_length1;
	_tmp11_ = splitted_basename;
	_tmp11__length1 = splitted_basename_length1;
	if (_tmp11__length1 == 1) {
		const gchar* _tmp12_;
		gchar* _tmp13_;
		_tmp12_ = _data11_->basename;
		_tmp13_ = g_strdup (_tmp12_);
		_g_free0 (_tmp10_);
		_tmp10_ = _tmp13_;
	} else {
		gchar** _tmp14_;
		gint _tmp14__length1;
		gchar** _tmp15_;
		gint _tmp15__length1;
		gchar* _tmp16_;
		_tmp14_ = splitted_basename;
		_tmp14__length1 = splitted_basename_length1;
		_tmp15_ = splitted_basename;
		_tmp15__length1 = splitted_basename_length1;
		_tmp16_ = _vala_g_strjoinv (".", _tmp14_ + 0, (_tmp15__length1 - 1) - 0);
		_g_free0 (_tmp10_);
		_tmp10_ = _tmp16_;
	}
	_tmp17_ = g_strdup (_tmp10_);
	_data11_->prefix = _tmp17_;
	_data11_->cover_path = NULL;
	_tmp18_ = _data11_->parent;
	_tmp19_ = games_directory_new (_tmp18_);
	directory = _tmp19_;
	_tmp20_ = directory;
	games_directory_foreach (_tmp20_, "*", ___lambda16__games_directory_file_info_test, _data11_, &_inner_error_);
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_propagate_error (error, _inner_error_);
		_g_object_unref0 (directory);
		_g_free0 (_tmp10_);
		splitted_basename = (_vala_array_free (splitted_basename, splitted_basename_length1, (GDestroyNotify) g_free), NULL);
		_g_object_unref0 (file);
		block11_data_unref (_data11_);
		_data11_ = NULL;
		return NULL;
	}
	_tmp21_ = _data11_->cover_path;
	_tmp22_ = g_strdup (_tmp21_);
	result = _tmp22_;
	_g_object_unref0 (directory);
	_g_free0 (_tmp10_);
	splitted_basename = (_vala_array_free (splitted_basename, splitted_basename_length1, (GDestroyNotify) g_free), NULL);
	_g_object_unref0 (file);
	block11_data_unref (_data11_);
	_data11_ = NULL;
	return result;
}


static Block12Data* block12_data_ref (Block12Data* _data12_) {
	g_atomic_int_inc (&_data12_->_ref_count_);
	return _data12_;
}


static void block12_data_unref (void * _userdata_) {
	Block12Data* _data12_;
	_data12_ = (Block12Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data12_->_ref_count_)) {
		GamesLocalCover* self;
		self = _data12_->self;
		_g_free0 (_data12_->cover_path);
		_g_object_unref0 (_data12_->parent);
		_g_object_unref0 (self);
		g_slice_free (Block12Data, _data12_);
	}
}


static gboolean __lambda17_ (Block12Data* _data12_, GFileInfo* sibbling, GError** error) {
	GamesLocalCover* self;
	gboolean result = FALSE;
	gchar* sibbling_basename = NULL;
	GFileInfo* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	gboolean _tmp3_ = FALSE;
	const gchar* _tmp4_;
	gboolean _tmp5_;
	gchar* type = NULL;
	GFileInfo* _tmp8_;
	const gchar* _tmp9_;
	gchar* _tmp10_;
	const gchar* _tmp11_;
	gboolean _tmp12_;
	GFile* sibbling_file = NULL;
	GFile* _tmp13_;
	const gchar* _tmp14_;
	GFile* _tmp15_;
	GFile* _tmp16_;
	gchar* _tmp17_;
	self = _data12_->self;
	g_return_val_if_fail (sibbling != NULL, FALSE);
	_tmp0_ = sibbling;
	_tmp1_ = g_file_info_get_name (_tmp0_);
	_tmp2_ = g_strdup (_tmp1_);
	sibbling_basename = _tmp2_;
	_tmp4_ = sibbling_basename;
	_tmp5_ = g_str_has_prefix (_tmp4_, "cover.");
	if (!_tmp5_) {
		const gchar* _tmp6_;
		gboolean _tmp7_;
		_tmp6_ = sibbling_basename;
		_tmp7_ = g_str_has_prefix (_tmp6_, "folder.");
		_tmp3_ = !_tmp7_;
	} else {
		_tmp3_ = FALSE;
	}
	if (_tmp3_) {
		result = FALSE;
		_g_free0 (sibbling_basename);
		return result;
	}
	_tmp8_ = sibbling;
	_tmp9_ = g_file_info_get_content_type (_tmp8_);
	_tmp10_ = g_strdup (_tmp9_);
	type = _tmp10_;
	_tmp11_ = type;
	_tmp12_ = g_str_has_prefix (_tmp11_, "image");
	if (!_tmp12_) {
		result = FALSE;
		_g_free0 (type);
		_g_free0 (sibbling_basename);
		return result;
	}
	_tmp13_ = _data12_->parent;
	_tmp14_ = sibbling_basename;
	_tmp15_ = g_file_get_child (_tmp13_, _tmp14_);
	sibbling_file = _tmp15_;
	_tmp16_ = sibbling_file;
	_tmp17_ = g_file_get_path (_tmp16_);
	_g_free0 (_data12_->cover_path);
	_data12_->cover_path = _tmp17_;
	result = TRUE;
	_g_object_unref0 (sibbling_file);
	_g_free0 (type);
	_g_free0 (sibbling_basename);
	return result;
}


static gboolean ___lambda17__games_directory_file_info_test (GFileInfo* file_info, gpointer self, GError** error) {
	gboolean result;
	result = __lambda17_ (self, file_info, error);
	return result;
}


static gchar* games_local_cover_get_directory_cover_path (GamesLocalCover* self, GError** error) {
	gchar* result = NULL;
	Block12Data* _data12_;
	GFile* file = NULL;
	GamesUri* _tmp0_;
	GFile* _tmp1_;
	GFile* _tmp2_;
	GFile* _tmp3_;
	GFile* _tmp4_;
	GamesDirectory* directory = NULL;
	GFile* _tmp5_;
	GamesDirectory* _tmp6_;
	GamesDirectory* _tmp7_;
	const gchar* _tmp8_;
	gchar* _tmp9_;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_data12_ = g_slice_new0 (Block12Data);
	_data12_->_ref_count_ = 1;
	_data12_->self = g_object_ref (self);
	_tmp0_ = self->priv->uri;
	_tmp1_ = games_uri_to_file (_tmp0_);
	file = _tmp1_;
	_tmp2_ = file;
	_tmp3_ = g_file_get_parent (_tmp2_);
	_data12_->parent = _tmp3_;
	_tmp4_ = _data12_->parent;
	if (_tmp4_ == NULL) {
		result = NULL;
		_g_object_unref0 (file);
		block12_data_unref (_data12_);
		_data12_ = NULL;
		return result;
	}
	_data12_->cover_path = NULL;
	_tmp5_ = _data12_->parent;
	_tmp6_ = games_directory_new (_tmp5_);
	directory = _tmp6_;
	_tmp7_ = directory;
	games_directory_foreach (_tmp7_, "*", ___lambda17__games_directory_file_info_test, _data12_, &_inner_error_);
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_propagate_error (error, _inner_error_);
		_g_object_unref0 (directory);
		_g_object_unref0 (file);
		block12_data_unref (_data12_);
		_data12_ = NULL;
		return NULL;
	}
	_tmp8_ = _data12_->cover_path;
	_tmp9_ = g_strdup (_tmp8_);
	result = _tmp9_;
	_g_object_unref0 (directory);
	_g_object_unref0 (file);
	block12_data_unref (_data12_);
	_data12_ = NULL;
	return result;
}


static void games_local_cover_class_init (GamesLocalCoverClass * klass) {
	games_local_cover_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (GamesLocalCoverPrivate));
	G_OBJECT_CLASS (klass)->finalize = games_local_cover_finalize;
}


static void games_local_cover_games_cover_interface_init (GamesCoverIface * iface) {
	games_local_cover_games_cover_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_cover = (GIcon* (*) (GamesCover *)) games_local_cover_real_get_cover;
}


static void games_local_cover_instance_init (GamesLocalCover * self) {
	self->priv = GAMES_LOCAL_COVER_GET_PRIVATE (self);
}


static void games_local_cover_finalize (GObject * obj) {
	GamesLocalCover * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_LOCAL_COVER, GamesLocalCover);
	_games_uri_unref0 (self->priv->uri);
	_g_object_unref0 (self->priv->icon);
	G_OBJECT_CLASS (games_local_cover_parent_class)->finalize (obj);
}


GType games_local_cover_get_type (void) {
	static volatile gsize games_local_cover_type_id__volatile = 0;
	if (g_once_init_enter (&games_local_cover_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (GamesLocalCoverClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_local_cover_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesLocalCover), 0, (GInstanceInitFunc) games_local_cover_instance_init, NULL };
		static const GInterfaceInfo games_cover_info = { (GInterfaceInitFunc) games_local_cover_games_cover_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
		GType games_local_cover_type_id;
		games_local_cover_type_id = g_type_register_static (G_TYPE_OBJECT, "GamesLocalCover", &g_define_type_info, 0);
		g_type_add_interface_static (games_local_cover_type_id, GAMES_TYPE_COVER, &games_cover_info);
		g_once_init_leave (&games_local_cover_type_id__volatile, games_local_cover_type_id);
	}
	return games_local_cover_type_id__volatile;
}


static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	if ((array != NULL) && (destroy_func != NULL)) {
		int i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}


static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}


static gint _vala_array_length (gpointer array) {
	int length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}



