/* wixl-heat.c generated by valac 0.42.5, the Vala compiler
 * generated from wixl-heat.vala, do not modify */



#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.h>
#include <stdio.h>
#include <gio/gio.h>
#include <libcommon.h>
#include <config.h>

#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_option_context_free0(var) ((var == NULL) ? NULL : (var = (g_option_context_free (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))


extern gchar* cg;
gchar* cg = NULL;
extern gchar* dr;
gchar* dr = NULL;
extern gchar* prefix;
gchar* prefix = NULL;
extern gchar* vardir;
gchar* vardir = NULL;
extern gchar** exclude;
gchar** exclude = NULL;
extern gboolean win64;
gboolean win64 = FALSE;

gboolean filtered (const gchar* file);
gchar* escape_filename (const gchar* filename);
gint _vala_main (gchar** args,
                 int args_length1);
static gchar** _vala_array_dup1 (gchar** self,
                          int length);
static void _g_free0_ (gpointer var);
static inline void _g_list_free__g_free0_ (GList* self);
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);

const GOptionEntry options[7] = {{"directory-ref", (gchar) 0, 0, G_OPTION_ARG_STRING, &dr, N_ ("Directory Ref"), NULL}, {"component-group", (gchar) 0, 0, G_OPTION_ARG_STRING, &cg, N_ ("Component Group"), NULL}, {"var", (gchar) 0, 0, G_OPTION_ARG_STRING, &vardir, N_ ("Variable for source dir"), NULL}, {"prefix", 'p', 0, G_OPTION_ARG_STRING, &prefix, N_ ("Prefix"), NULL}, {"exclude", 'x', 0, G_OPTION_ARG_STRING_ARRAY, &exclude, N_ ("Exclude prefix"), NULL}, {"win64", (gchar) 0, 0, G_OPTION_ARG_NONE, &win64, N_ ("Add Win64 Component"), NULL}, {NULL}};

gboolean
filtered (const gchar* file)
{
	gboolean result = FALSE;
	gchar** _tmp0_;
	gint _tmp0__length1;
	g_return_val_if_fail (file != NULL, FALSE);
	_tmp0_ = exclude;
	_tmp0__length1 = _vala_array_length (exclude);
	{
		gchar** f_collection = NULL;
		gint f_collection_length1 = 0;
		gint _f_collection_size_ = 0;
		gint f_it = 0;
		f_collection = _tmp0_;
		f_collection_length1 = _tmp0__length1;
		for (f_it = 0; f_it < _tmp0__length1; f_it = f_it + 1) {
			gchar* _tmp1_;
			gchar* f = NULL;
			_tmp1_ = g_strdup (f_collection[f_it]);
			f = _tmp1_;
			{
				const gchar* _tmp2_;
				_tmp2_ = f;
				if (g_str_has_prefix (file, _tmp2_)) {
					result = TRUE;
					_g_free0 (f);
					return result;
				}
				_g_free0 (f);
			}
		}
	}
	result = FALSE;
	return result;
}


static gchar*
string_replace (const gchar* self,
                const gchar* old,
                const gchar* replacement)
{
	gchar* result = NULL;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (old != NULL, NULL);
	g_return_val_if_fail (replacement != NULL, NULL);
	if ((*((gchar*) self)) == '\0') {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = (*((gchar*) old)) == '\0';
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = g_strcmp0 (old, replacement) == 0;
	}
	if (_tmp0_) {
		gchar* _tmp2_;
		_tmp2_ = g_strdup (self);
		result = _tmp2_;
		return result;
	}
	{
		GRegex* regex = NULL;
		gchar* _tmp3_;
		gchar* _tmp4_;
		GRegex* _tmp5_;
		GRegex* _tmp6_;
		gchar* _tmp7_ = NULL;
		GRegex* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		_tmp3_ = g_regex_escape_string (old, -1);
		_tmp4_ = _tmp3_;
		_tmp5_ = g_regex_new (_tmp4_, 0, 0, &_inner_error_);
		_tmp6_ = _tmp5_;
		_g_free0 (_tmp4_);
		regex = _tmp6_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			if (_inner_error_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected 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_ = regex;
		_tmp9_ = g_regex_replace_literal (_tmp8_, self, (gssize) -1, 0, replacement, 0, &_inner_error_);
		_tmp7_ = _tmp9_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			_g_regex_unref0 (regex);
			if (_inner_error_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			_g_regex_unref0 (regex);
			g_critical ("file %s: line %d: unexpected 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;
		}
		_tmp10_ = _tmp7_;
		_tmp7_ = NULL;
		result = _tmp10_;
		_g_free0 (_tmp7_);
		_g_regex_unref0 (regex);
		return result;
	}
	goto __finally0;
	__catch0_g_regex_error:
	{
		GError* e = NULL;
		e = _inner_error_;
		_inner_error_ = NULL;
		g_assert_not_reached ();
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		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;
	}
}


gchar*
escape_filename (const gchar* filename)
{
	gchar* result = NULL;
	gchar* _tmp0_;
	g_return_val_if_fail (filename != NULL, NULL);
	_tmp0_ = string_replace (filename, "$", "$$");
	result = _tmp0_;
	return result;
}


static gchar*
_vala_g_strjoinv (const gchar* separator,
                  gchar** str_array,
                  int str_array_length1)
{
	gchar* result = NULL;
	gboolean _tmp0_ = FALSE;
	if (separator == NULL) {
		separator = "";
	}
	if (str_array != NULL) {
		gboolean _tmp1_ = FALSE;
		if (str_array_length1 > 0) {
			_tmp1_ = TRUE;
		} else {
			gboolean _tmp2_ = FALSE;
			if (str_array_length1 == -1) {
				const gchar* _tmp3_;
				_tmp3_ = str_array[0];
				_tmp2_ = _tmp3_ != NULL;
			} else {
				_tmp2_ = FALSE;
			}
			_tmp1_ = _tmp2_;
		}
		_tmp0_ = _tmp1_;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		gint i = 0;
		gsize len = 0UL;
		gint _tmp20_;
		gint _tmp22_;
		gsize _tmp23_;
		gint _tmp24_;
		gint _tmp25_;
		gint _tmp26_;
		const gchar* res = NULL;
		gsize _tmp27_;
		void* _tmp28_;
		void* ptr = NULL;
		const gchar* _tmp29_;
		const gchar* _tmp30_;
		void* _tmp31_;
		const gchar* _tmp44_;
		len = (gsize) 1;
		{
			gboolean _tmp4_ = FALSE;
			i = 0;
			_tmp4_ = TRUE;
			while (TRUE) {
				gboolean _tmp6_ = FALSE;
				gboolean _tmp7_ = FALSE;
				gint _tmp12_ = 0;
				gint _tmp13_;
				const gchar* _tmp14_;
				gsize _tmp19_;
				if (!_tmp4_) {
					gint _tmp5_;
					_tmp5_ = i;
					i = _tmp5_ + 1;
				}
				_tmp4_ = FALSE;
				if (str_array_length1 != -1) {
					gint _tmp8_;
					_tmp8_ = i;
					_tmp7_ = _tmp8_ < str_array_length1;
				} else {
					_tmp7_ = FALSE;
				}
				if (_tmp7_) {
					_tmp6_ = TRUE;
				} else {
					gboolean _tmp9_ = FALSE;
					if (str_array_length1 == -1) {
						gint _tmp10_;
						const gchar* _tmp11_;
						_tmp10_ = i;
						_tmp11_ = str_array[_tmp10_];
						_tmp9_ = _tmp11_ != NULL;
					} else {
						_tmp9_ = FALSE;
					}
					_tmp6_ = _tmp9_;
				}
				if (!_tmp6_) {
					break;
				}
				_tmp13_ = i;
				_tmp14_ = str_array[_tmp13_];
				if (_tmp14_ != NULL) {
					gint _tmp15_;
					const gchar* _tmp16_;
					gint _tmp17_;
					gint _tmp18_;
					_tmp15_ = i;
					_tmp16_ = str_array[_tmp15_];
					_tmp17_ = strlen ((const gchar*) _tmp16_);
					_tmp18_ = _tmp17_;
					_tmp12_ = _tmp18_;
				} else {
					_tmp12_ = 0;
				}
				_tmp19_ = len;
				len = _tmp19_ + _tmp12_;
			}
		}
		_tmp20_ = i;
		if (_tmp20_ == 0) {
			gchar* _tmp21_;
			_tmp21_ = g_strdup ("");
			result = _tmp21_;
			return result;
		}
		_tmp22_ = i;
		str_array_length1 = _tmp22_;
		_tmp23_ = len;
		_tmp24_ = strlen ((const gchar*) separator);
		_tmp25_ = _tmp24_;
		_tmp26_ = i;
		len = _tmp23_ + (_tmp25_ * (_tmp26_ - 1));
		_tmp27_ = len;
		_tmp28_ = g_malloc (_tmp27_);
		res = _tmp28_;
		_tmp29_ = res;
		_tmp30_ = str_array[0];
		_tmp31_ = g_stpcpy ((void*) _tmp29_, (const gchar*) _tmp30_);
		ptr = _tmp31_;
		{
			gboolean _tmp32_ = FALSE;
			i = 1;
			_tmp32_ = TRUE;
			while (TRUE) {
				gint _tmp34_;
				void* _tmp35_;
				void* _tmp36_;
				const gchar* _tmp37_ = NULL;
				gint _tmp38_;
				const gchar* _tmp39_;
				void* _tmp42_;
				void* _tmp43_;
				if (!_tmp32_) {
					gint _tmp33_;
					_tmp33_ = i;
					i = _tmp33_ + 1;
				}
				_tmp32_ = FALSE;
				_tmp34_ = i;
				if (!(_tmp34_ < str_array_length1)) {
					break;
				}
				_tmp35_ = ptr;
				_tmp36_ = g_stpcpy (_tmp35_, (const gchar*) separator);
				ptr = _tmp36_;
				_tmp38_ = i;
				_tmp39_ = str_array[_tmp38_];
				if (_tmp39_ != NULL) {
					gint _tmp40_;
					const gchar* _tmp41_;
					_tmp40_ = i;
					_tmp41_ = str_array[_tmp40_];
					_tmp37_ = (const gchar*) _tmp41_;
				} else {
					_tmp37_ = "";
				}
				_tmp42_ = ptr;
				_tmp43_ = g_stpcpy (_tmp42_, _tmp37_);
				ptr = _tmp43_;
			}
		}
		_tmp44_ = res;
		res = NULL;
		result = (gchar*) _tmp44_;
		return result;
	} else {
		gchar* _tmp45_;
		_tmp45_ = g_strdup ("");
		result = _tmp45_;
		return result;
	}
}


static gchar*
string_slice (const gchar* self,
              glong start,
              glong end)
{
	gchar* result = NULL;
	glong string_length = 0L;
	gint _tmp0_;
	gint _tmp1_;
	gboolean _tmp4_ = FALSE;
	gboolean _tmp6_ = FALSE;
	gchar* _tmp8_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = strlen (self);
	_tmp1_ = _tmp0_;
	string_length = (glong) _tmp1_;
	if (start < ((glong) 0)) {
		glong _tmp2_;
		_tmp2_ = string_length;
		start = _tmp2_ + start;
	}
	if (end < ((glong) 0)) {
		glong _tmp3_;
		_tmp3_ = string_length;
		end = _tmp3_ + end;
	}
	if (start >= ((glong) 0)) {
		glong _tmp5_;
		_tmp5_ = string_length;
		_tmp4_ = start <= _tmp5_;
	} else {
		_tmp4_ = FALSE;
	}
	g_return_val_if_fail (_tmp4_, NULL);
	if (end >= ((glong) 0)) {
		glong _tmp7_;
		_tmp7_ = string_length;
		_tmp6_ = end <= _tmp7_;
	} else {
		_tmp6_ = FALSE;
	}
	g_return_val_if_fail (_tmp6_, NULL);
	g_return_val_if_fail (start <= end, NULL);
	_tmp8_ = g_strndup (((gchar*) self) + start, (gsize) (end - start));
	result = _tmp8_;
	return result;
}


static gchar**
_vala_array_dup1 (gchar** self,
                  int length)
{
	gchar** result;
	int i;
	result = g_new0 (gchar*, length + 1);
	for (i = 0; i < length; i++) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (self[i]);
		result[i] = _tmp0_;
	}
	return result;
}


static void
_g_free0_ (gpointer var)
{
	var = (g_free (var), NULL);
}


static inline void
_g_list_free__g_free0_ (GList* self)
{
	g_list_free_full (self, (GDestroyNotify) _g_free0_);
}


gint
_vala_main (gchar** args,
            int args_length1)
{
	gint result = 0;
	gchar* cmdline = NULL;
	gchar* _tmp0_;
	GOptionContext* opt_context = NULL;
	GOptionContext* _tmp1_;
	GOptionContext* _tmp2_;
	GOptionContext* _tmp3_;
	gchar* _tmp4_;
	gchar* sourcedir = NULL;
	gchar* _tmp5_;
	const gchar* _tmp15_;
	const gchar* _tmp17_;
	FILE* _tmp20_;
	FILE* _tmp21_;
	FILE* _tmp22_;
	FILE* _tmp23_;
	const gchar* _tmp24_;
	gchar* _tmp25_;
	gchar* _tmp26_;
	gchar** last_path = NULL;
	gint last_path_length1;
	gint _last_path_size_;
	GList* cmpref = NULL;
	gchar* indent = NULL;
	gchar* _tmp27_;
	const gchar* _tmp151_;
	gchar* _tmp152_;
	gchar** _tmp153_;
	gint _tmp153__length1;
	FILE* _tmp161_;
	FILE* _tmp162_;
	const gchar* _tmp163_;
	FILE* _tmp177_;
	FILE* _tmp178_;
	FILE* _tmp179_;
	const gchar* _tmp180_;
	gchar* _tmp181_;
	gchar* _tmp182_;
	GError * _inner_error_ = NULL;
	_tmp0_ = _vala_g_strjoinv (" ", args, args_length1);
	cmdline = _tmp0_;
	_tmp1_ = g_option_context_new ("");
	opt_context = _tmp1_;
	_tmp2_ = opt_context;
	g_option_context_set_help_enabled (_tmp2_, TRUE);
	_tmp3_ = opt_context;
	g_option_context_add_main_entries (_tmp3_, options, NULL);
	_tmp4_ = g_strdup ("TARGETDIR");
	_g_free0 (dr);
	dr = _tmp4_;
	_tmp5_ = g_strdup ("SourceDir");
	sourcedir = _tmp5_;
	{
		GOptionContext* _tmp6_;
		_tmp6_ = opt_context;
		g_option_context_parse (_tmp6_, &args_length1, &args, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			gint _tmp7_ = -1;
			if (g_error_matches (_inner_error_, G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE)) {
				goto __catch1_g_option_error_bad_value;
			}
			if (_inner_error_->domain == G_OPTION_ERROR) {
				goto __catch1_g_option_error;
			}
			_g_free0 (sourcedir);
			_g_option_context_free0 (opt_context);
			_g_free0 (cmdline);
			g_critical ("file %s: line %d: unexpected 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 _tmp7_;
		}
	}
	goto __finally1;
	__catch1_g_option_error_bad_value:
	{
		GError* err = NULL;
		FILE* _tmp8_;
		GOptionContext* _tmp9_;
		gchar* _tmp10_;
		gchar* _tmp11_;
		err = _inner_error_;
		_inner_error_ = NULL;
		_tmp8_ = stdout;
		_tmp9_ = opt_context;
		_tmp10_ = g_option_context_get_help (_tmp9_, TRUE, NULL);
		_tmp11_ = _tmp10_;
		fprintf (_tmp8_, "%s", _tmp11_);
		_g_free0 (_tmp11_);
		result = 1;
		_g_error_free0 (err);
		_g_free0 (sourcedir);
		_g_option_context_free0 (opt_context);
		_g_free0 (cmdline);
		return result;
	}
	goto __finally1;
	__catch1_g_option_error:
	{
		GError* _error_ = NULL;
		GError* _tmp12_;
		const gchar* _tmp13_;
		_error_ = _inner_error_;
		_inner_error_ = NULL;
		_tmp12_ = _error_;
		_tmp13_ = _tmp12_->message;
		g_warning ("wixl-heat.vala:50: %s", _tmp13_);
		_g_error_free0 (_error_);
	}
	__finally1:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		gint _tmp14_ = -1;
		_g_free0 (sourcedir);
		_g_option_context_free0 (opt_context);
		_g_free0 (cmdline);
		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 _tmp14_;
	}
	_tmp15_ = prefix;
	if (_tmp15_ == NULL) {
		FILE* _tmp16_;
		_tmp16_ = stderr;
		fprintf (_tmp16_, "Please specify source dir prefix\n");
		result = 1;
		_g_free0 (sourcedir);
		_g_option_context_free0 (opt_context);
		_g_free0 (cmdline);
		return result;
	}
	_tmp17_ = vardir;
	if (_tmp17_ != NULL) {
		const gchar* _tmp18_;
		gchar* _tmp19_;
		_tmp18_ = vardir;
		_tmp19_ = g_strdup_printf ("$(%s)", _tmp18_);
		_g_free0 (sourcedir);
		sourcedir = _tmp19_;
	}
	_tmp20_ = stdout;
	fprintf (_tmp20_, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
	_tmp21_ = stdout;
	fprintf (_tmp21_, "<Wix xmlns=\"http://schemas.microsoft.com/wix/2006/wi\">\n");
	_tmp22_ = stdout;
	fprintf (_tmp22_, "  <Fragment>\n");
	_tmp23_ = stdout;
	_tmp24_ = dr;
	_tmp25_ = g_strdup_printf ("    <DirectoryRef Id=\"%s\">\n", _tmp24_);
	_tmp26_ = _tmp25_;
	fprintf (_tmp23_, "%s", _tmp26_);
	_g_free0 (_tmp26_);
	last_path = NULL;
	last_path_length1 = 0;
	_last_path_size_ = last_path_length1;
	cmpref = NULL;
	_tmp27_ = g_strdup ("      ");
	indent = _tmp27_;
	{
		GDataInputStream* dis = NULL;
		WixlUnixInputStream* _tmp28_;
		WixlUnixInputStream* _tmp29_;
		GDataInputStream* _tmp30_;
		GDataInputStream* _tmp31_;
		gchar* line = NULL;
		_tmp28_ = wixl_unix_input_stream_new (0);
		_tmp29_ = _tmp28_;
		_tmp30_ = g_data_input_stream_new ((GInputStream*) _tmp29_);
		_tmp31_ = _tmp30_;
		_g_object_unref0 (_tmp29_);
		dis = _tmp31_;
		while (TRUE) {
			gchar* _tmp32_ = NULL;
			GDataInputStream* _tmp33_;
			gchar* _tmp34_;
			gchar* _tmp35_;
			const gchar* _tmp36_;
			const gchar* _tmp37_;
			const gchar* _tmp38_;
			gchar* file = NULL;
			const gchar* _tmp39_;
			const gchar* _tmp40_;
			gint _tmp41_;
			gint _tmp42_;
			const gchar* _tmp43_;
			gint _tmp44_;
			gint _tmp45_;
			gchar* _tmp46_;
			const gchar* _tmp47_;
			GFile* gfile = NULL;
			const gchar* _tmp48_;
			GFile* _tmp49_;
			gboolean is_directory = FALSE;
			GFile* _tmp50_;
			gchar* _tmp51_ = NULL;
			gboolean _tmp52_;
			gchar* dir = NULL;
			gchar* _tmp57_;
			gchar** path = NULL;
			const gchar* _tmp58_;
			gchar** _tmp59_;
			gchar** _tmp60_;
			gint path_length1;
			gint _path_size_;
			gint i = 0;
			gchar** _tmp61_;
			gint _tmp61__length1;
			gchar** _tmp105_;
			gint _tmp105__length1;
			gchar** _tmp106_;
			gint _tmp106__length1;
			gboolean _tmp107_;
			_tmp33_ = dis;
			_tmp34_ = g_data_input_stream_read_line (_tmp33_, NULL, NULL, &_inner_error_);
			_tmp32_ = _tmp34_;
			if (G_UNLIKELY (_inner_error_ != NULL)) {
				_g_free0 (line);
				_g_object_unref0 (dis);
				goto __catch2_g_error;
			}
			_tmp35_ = _tmp32_;
			_tmp32_ = NULL;
			_g_free0 (line);
			line = _tmp35_;
			_tmp36_ = line;
			if (!(_tmp36_ != NULL)) {
				_g_free0 (_tmp32_);
				break;
			}
			_tmp37_ = line;
			_tmp38_ = prefix;
			if (!g_str_has_prefix (_tmp37_, _tmp38_)) {
				_g_free0 (_tmp32_);
				continue;
			}
			_tmp39_ = line;
			_tmp40_ = prefix;
			_tmp41_ = strlen (_tmp40_);
			_tmp42_ = _tmp41_;
			_tmp43_ = line;
			_tmp44_ = strlen (_tmp43_);
			_tmp45_ = _tmp44_;
			_tmp46_ = string_slice (_tmp39_, (glong) _tmp42_, (glong) _tmp45_);
			file = _tmp46_;
			_tmp47_ = file;
			if (filtered (_tmp47_)) {
				_g_free0 (file);
				_g_free0 (_tmp32_);
				continue;
			}
			_tmp48_ = line;
			_tmp49_ = g_file_new_for_path (_tmp48_);
			gfile = _tmp49_;
			_tmp50_ = gfile;
			is_directory = g_file_query_file_type (_tmp50_, G_FILE_QUERY_INFO_NONE, NULL) == G_FILE_TYPE_DIRECTORY;
			_tmp52_ = is_directory;
			if (_tmp52_) {
				const gchar* _tmp53_;
				gchar* _tmp54_;
				_tmp53_ = file;
				_tmp54_ = g_strdup (_tmp53_);
				_g_free0 (_tmp51_);
				_tmp51_ = _tmp54_;
			} else {
				const gchar* _tmp55_;
				gchar* _tmp56_;
				_tmp55_ = file;
				_tmp56_ = g_path_get_dirname (_tmp55_);
				_g_free0 (_tmp51_);
				_tmp51_ = _tmp56_;
			}
			_tmp57_ = g_strdup (_tmp51_);
			dir = _tmp57_;
			_tmp58_ = dir;
			_tmp60_ = _tmp59_ = g_strsplit (_tmp58_, G_DIR_SEPARATOR_S, -1);
			path = _tmp60_;
			path_length1 = _vala_array_length (_tmp59_);
			_path_size_ = path_length1;
			i = 0;
			_tmp61_ = last_path;
			_tmp61__length1 = last_path_length1;
			if (_tmp61_ != NULL) {
				while (TRUE) {
					gboolean _tmp62_ = FALSE;
					gboolean _tmp63_ = FALSE;
					gchar** _tmp64_;
					gint _tmp64__length1;
					gint _tmp65_;
					const gchar* _tmp66_;
					gint _tmp76_;
					_tmp64_ = path;
					_tmp64__length1 = path_length1;
					_tmp65_ = i;
					_tmp66_ = _tmp64_[_tmp65_];
					if (_tmp66_ != NULL) {
						gchar** _tmp67_;
						gint _tmp67__length1;
						gint _tmp68_;
						const gchar* _tmp69_;
						_tmp67_ = last_path;
						_tmp67__length1 = last_path_length1;
						_tmp68_ = i;
						_tmp69_ = _tmp67_[_tmp68_];
						_tmp63_ = _tmp69_ != NULL;
					} else {
						_tmp63_ = FALSE;
					}
					if (_tmp63_) {
						gchar** _tmp70_;
						gint _tmp70__length1;
						gint _tmp71_;
						const gchar* _tmp72_;
						gchar** _tmp73_;
						gint _tmp73__length1;
						gint _tmp74_;
						const gchar* _tmp75_;
						_tmp70_ = path;
						_tmp70__length1 = path_length1;
						_tmp71_ = i;
						_tmp72_ = _tmp70_[_tmp71_];
						_tmp73_ = last_path;
						_tmp73__length1 = last_path_length1;
						_tmp74_ = i;
						_tmp75_ = _tmp73_[_tmp74_];
						_tmp62_ = g_strcmp0 (_tmp72_, _tmp75_) == 0;
					} else {
						_tmp62_ = FALSE;
					}
					if (!_tmp62_) {
						break;
					}
					_tmp76_ = i;
					i = _tmp76_ + 1;
				}
				{
					gint j = 0;
					gchar** _tmp77_;
					gint _tmp77__length1;
					gint _tmp78_;
					_tmp77_ = last_path;
					_tmp77__length1 = last_path_length1;
					_tmp78_ = i;
					j = _tmp77__length1 - _tmp78_;
					{
						gboolean _tmp79_ = FALSE;
						_tmp79_ = TRUE;
						while (TRUE) {
							gint _tmp81_;
							const gchar* _tmp82_;
							gchar* _tmp83_;
							FILE* _tmp84_;
							const gchar* _tmp85_;
							gchar* _tmp86_;
							gchar* _tmp87_;
							if (!_tmp79_) {
								gint _tmp80_;
								_tmp80_ = j;
								j = _tmp80_ - 1;
							}
							_tmp79_ = FALSE;
							_tmp81_ = j;
							if (!(_tmp81_ > 0)) {
								break;
							}
							_tmp82_ = indent;
							_tmp83_ = string_slice (_tmp82_, (glong) 0, (glong) -2);
							_g_free0 (indent);
							indent = _tmp83_;
							_tmp84_ = stdout;
							_tmp85_ = indent;
							_tmp86_ = g_strconcat (_tmp85_, "</Directory>\n", NULL);
							_tmp87_ = _tmp86_;
							fprintf (_tmp84_, "%s", _tmp87_);
							_g_free0 (_tmp87_);
						}
					}
				}
			}
			{
				gboolean _tmp88_ = FALSE;
				_tmp88_ = TRUE;
				while (TRUE) {
					gint _tmp90_;
					gchar** _tmp91_;
					gint _tmp91__length1;
					FILE* _tmp92_;
					const gchar* _tmp93_;
					gchar* _tmp94_;
					gchar* _tmp95_;
					gchar** _tmp96_;
					gint _tmp96__length1;
					gint _tmp97_;
					const gchar* _tmp98_;
					gchar* _tmp99_;
					gchar* _tmp100_;
					gchar* _tmp101_;
					gchar* _tmp102_;
					const gchar* _tmp103_;
					gchar* _tmp104_;
					if (!_tmp88_) {
						gint _tmp89_;
						_tmp89_ = i;
						i = _tmp89_ + 1;
					}
					_tmp88_ = FALSE;
					_tmp90_ = i;
					_tmp91_ = path;
					_tmp91__length1 = path_length1;
					if (!(_tmp90_ < _tmp91__length1)) {
						break;
					}
					_tmp92_ = stdout;
					_tmp93_ = indent;
					_tmp94_ = wixl_random_id ("dir");
					_tmp95_ = _tmp94_;
					_tmp96_ = path;
					_tmp96__length1 = path_length1;
					_tmp97_ = i;
					_tmp98_ = _tmp96_[_tmp97_];
					_tmp99_ = g_strdup_printf ("<Directory Id=\"%s\" Name=\"%s\">\n", _tmp95_, _tmp98_);
					_tmp100_ = _tmp99_;
					_tmp101_ = g_strconcat (_tmp93_, _tmp100_, NULL);
					_tmp102_ = _tmp101_;
					fprintf (_tmp92_, "%s", _tmp102_);
					_g_free0 (_tmp102_);
					_g_free0 (_tmp100_);
					_g_free0 (_tmp95_);
					_tmp103_ = indent;
					_tmp104_ = g_strconcat (_tmp103_, "  ", NULL);
					_g_free0 (indent);
					indent = _tmp104_;
				}
			}
			_tmp105_ = path;
			_tmp105__length1 = path_length1;
			_tmp106_ = (_tmp105_ != NULL) ? _vala_array_dup1 (_tmp105_, _tmp105__length1) : ((gpointer) _tmp105_);
			_tmp106__length1 = _tmp105__length1;
			last_path = (_vala_array_free (last_path, last_path_length1, (GDestroyNotify) g_free), NULL);
			last_path = _tmp106_;
			last_path_length1 = _tmp106__length1;
			_last_path_size_ = last_path_length1;
			_tmp107_ = is_directory;
			if (!_tmp107_) {
				gchar* id = NULL;
				const gchar* _tmp108_;
				gchar* _tmp109_;
				const gchar* _tmp110_;
				gchar* _tmp111_;
				gboolean _tmp112_;
				const gchar* _tmp127_;
				gchar* _tmp128_;
				gchar* _tmp129_;
				const gchar* _tmp130_;
				gchar* _tmp131_;
				gchar* _tmp132_;
				gchar* _tmp133_;
				FILE* _tmp134_;
				const gchar* _tmp135_;
				const gchar* _tmp136_;
				gchar* _tmp137_;
				gchar* _tmp138_;
				const gchar* _tmp139_;
				gchar* _tmp140_;
				gchar* _tmp141_;
				gchar* _tmp142_;
				gchar* _tmp143_;
				FILE* _tmp144_;
				const gchar* _tmp145_;
				gchar* _tmp146_;
				gchar* _tmp147_;
				_tmp108_ = file;
				_tmp109_ = wixl_generate_id ("cmp", (guint) 1, _tmp108_, NULL);
				id = _tmp109_;
				_tmp110_ = id;
				_tmp111_ = g_strdup (_tmp110_);
				cmpref = g_list_append (cmpref, _tmp111_);
				_tmp112_ = win64;
				if (_tmp112_) {
					FILE* _tmp113_;
					const gchar* _tmp114_;
					const gchar* _tmp115_;
					gchar* _tmp116_;
					gchar* _tmp117_;
					gchar* _tmp118_;
					gchar* _tmp119_;
					_tmp113_ = stdout;
					_tmp114_ = indent;
					_tmp115_ = id;
					_tmp116_ = g_strdup_printf ("<Component Win64=\"$(var.Win64)\" Id=\"%s\" Guid=\"*\">\n", _tmp115_);
					_tmp117_ = _tmp116_;
					_tmp118_ = g_strconcat (_tmp114_, _tmp117_, NULL);
					_tmp119_ = _tmp118_;
					fprintf (_tmp113_, "%s", _tmp119_);
					_g_free0 (_tmp119_);
					_g_free0 (_tmp117_);
				} else {
					FILE* _tmp120_;
					const gchar* _tmp121_;
					const gchar* _tmp122_;
					gchar* _tmp123_;
					gchar* _tmp124_;
					gchar* _tmp125_;
					gchar* _tmp126_;
					_tmp120_ = stdout;
					_tmp121_ = indent;
					_tmp122_ = id;
					_tmp123_ = g_strdup_printf ("<Component Id=\"%s\" Guid=\"*\">\n", _tmp122_);
					_tmp124_ = _tmp123_;
					_tmp125_ = g_strconcat (_tmp121_, _tmp124_, NULL);
					_tmp126_ = _tmp125_;
					fprintf (_tmp120_, "%s", _tmp126_);
					_g_free0 (_tmp126_);
					_g_free0 (_tmp124_);
				}
				_tmp127_ = sourcedir;
				_tmp128_ = g_strconcat (_tmp127_, G_DIR_SEPARATOR_S, NULL);
				_tmp129_ = _tmp128_;
				_tmp130_ = file;
				_tmp131_ = escape_filename (_tmp130_);
				_tmp132_ = _tmp131_;
				_tmp133_ = g_strconcat (_tmp129_, _tmp132_, NULL);
				_g_free0 (file);
				file = _tmp133_;
				_g_free0 (_tmp132_);
				_g_free0 (_tmp129_);
				_tmp134_ = stdout;
				_tmp135_ = indent;
				_tmp136_ = file;
				_tmp137_ = wixl_generate_id ("fil", (guint) 1, _tmp136_, NULL);
				_tmp138_ = _tmp137_;
				_tmp139_ = file;
				_tmp140_ = g_strdup_printf ("  <File Id=\"%s\" KeyPath=\"yes\" Source=\"%s\"/>\n", _tmp138_, _tmp139_);
				_tmp141_ = _tmp140_;
				_tmp142_ = g_strconcat (_tmp135_, _tmp141_, NULL);
				_tmp143_ = _tmp142_;
				fprintf (_tmp134_, "%s", _tmp143_);
				_g_free0 (_tmp143_);
				_g_free0 (_tmp141_);
				_g_free0 (_tmp138_);
				_tmp144_ = stdout;
				_tmp145_ = indent;
				_tmp146_ = g_strconcat (_tmp145_, "</Component>\n", NULL);
				_tmp147_ = _tmp146_;
				fprintf (_tmp144_, "%s", _tmp147_);
				_g_free0 (_tmp147_);
				_g_free0 (id);
			}
			path = (_vala_array_free (path, path_length1, (GDestroyNotify) g_free), NULL);
			_g_free0 (dir);
			_g_free0 (_tmp51_);
			_g_object_unref0 (gfile);
			_g_free0 (file);
			_g_free0 (_tmp32_);
		}
		_g_free0 (line);
		_g_object_unref0 (dis);
	}
	goto __finally2;
	__catch2_g_error:
	{
		GError* _error_ = NULL;
		GError* _tmp148_;
		const gchar* _tmp149_;
		_error_ = _inner_error_;
		_inner_error_ = NULL;
		_tmp148_ = _error_;
		_tmp149_ = _tmp148_->message;
		g_warning ("wixl-heat.vala:115: %s", _tmp149_);
		_g_error_free0 (_error_);
	}
	__finally2:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		gint _tmp150_ = -1;
		_g_free0 (indent);
		(cmpref == NULL) ? NULL : (cmpref = (_g_list_free__g_free0_ (cmpref), NULL));
		last_path = (_vala_array_free (last_path, last_path_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (sourcedir);
		_g_option_context_free0 (opt_context);
		_g_free0 (cmdline);
		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 _tmp150_;
	}
	_tmp151_ = indent;
	_tmp152_ = string_slice (_tmp151_, (glong) 0, (glong) -2);
	_g_free0 (indent);
	indent = _tmp152_;
	_tmp153_ = last_path;
	_tmp153__length1 = last_path_length1;
	{
		gchar** l_collection = NULL;
		gint l_collection_length1 = 0;
		gint _l_collection_size_ = 0;
		gint l_it = 0;
		l_collection = _tmp153_;
		l_collection_length1 = _tmp153__length1;
		for (l_it = 0; l_it < _tmp153__length1; l_it = l_it + 1) {
			gchar* _tmp154_;
			gchar* l = NULL;
			_tmp154_ = g_strdup (l_collection[l_it]);
			l = _tmp154_;
			{
				FILE* _tmp155_;
				const gchar* _tmp156_;
				gchar* _tmp157_;
				gchar* _tmp158_;
				const gchar* _tmp159_;
				gchar* _tmp160_;
				_tmp155_ = stdout;
				_tmp156_ = indent;
				_tmp157_ = g_strconcat (_tmp156_, "</Directory>\n", NULL);
				_tmp158_ = _tmp157_;
				fprintf (_tmp155_, "%s", _tmp158_);
				_g_free0 (_tmp158_);
				_tmp159_ = indent;
				_tmp160_ = string_slice (_tmp159_, (glong) 0, (glong) -2);
				_g_free0 (indent);
				indent = _tmp160_;
				_g_free0 (l);
			}
		}
	}
	_tmp161_ = stdout;
	fprintf (_tmp161_, "    </DirectoryRef>\n");
	_tmp162_ = stdout;
	fprintf (_tmp162_, "  </Fragment>\n");
	_tmp163_ = cg;
	if (_tmp163_ != NULL) {
		FILE* _tmp164_;
		FILE* _tmp165_;
		const gchar* _tmp166_;
		gchar* _tmp167_;
		gchar* _tmp168_;
		GList* _tmp169_;
		FILE* _tmp175_;
		FILE* _tmp176_;
		_tmp164_ = stdout;
		fprintf (_tmp164_, "  <Fragment>\n");
		_tmp165_ = stdout;
		_tmp166_ = cg;
		_tmp167_ = g_strdup_printf ("    <ComponentGroup Id=\"%s\">\n", _tmp166_);
		_tmp168_ = _tmp167_;
		fprintf (_tmp165_, "%s", _tmp168_);
		_g_free0 (_tmp168_);
		_tmp169_ = cmpref;
		{
			GList* id_collection = NULL;
			GList* id_it = NULL;
			id_collection = _tmp169_;
			for (id_it = id_collection; id_it != NULL; id_it = id_it->next) {
				gchar* _tmp170_;
				gchar* id = NULL;
				_tmp170_ = g_strdup ((const gchar*) id_it->data);
				id = _tmp170_;
				{
					FILE* _tmp171_;
					const gchar* _tmp172_;
					gchar* _tmp173_;
					gchar* _tmp174_;
					_tmp171_ = stdout;
					_tmp172_ = id;
					_tmp173_ = g_strdup_printf ("      <ComponentRef Id=\"%s\"/>\n", _tmp172_);
					_tmp174_ = _tmp173_;
					fprintf (_tmp171_, "%s", _tmp174_);
					_g_free0 (_tmp174_);
					_g_free0 (id);
				}
			}
		}
		_tmp175_ = stdout;
		fprintf (_tmp175_, "    </ComponentGroup>\n");
		_tmp176_ = stdout;
		fprintf (_tmp176_, "  </Fragment>\n");
	}
	_tmp177_ = stdout;
	fprintf (_tmp177_, "</Wix>\n");
	_tmp178_ = stdout;
	fprintf (_tmp178_, "<!-- generated with %s -->\n", PACKAGE_STRING);
	_tmp179_ = stdout;
	_tmp180_ = cmdline;
	_tmp181_ = string_replace (_tmp180_, "--", "-");
	_tmp182_ = _tmp181_;
	fprintf (_tmp179_, "<!-- %s -->\n", _tmp182_);
	_g_free0 (_tmp182_);
	result = 0;
	_g_free0 (indent);
	(cmpref == NULL) ? NULL : (cmpref = (_g_list_free__g_free0_ (cmpref), NULL));
	last_path = (_vala_array_free (last_path, last_path_length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (sourcedir);
	_g_option_context_free0 (opt_context);
	_g_free0 (cmdline);
	return result;
}


int
main (int argc,
      char ** argv)
{
	return _vala_main (argv, argc);
}


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;
}



