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

#include <stdlib.h>
#include <string.h>
#include <glib.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,
                 gint 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)
{
	gchar** _tmp0_;
	gint _tmp0__length1;
	gboolean result = FALSE;
	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 < f_collection_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)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	GError* _inner_error0_ = NULL;
	gchar* result = 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_error0_);
		_tmp6_ = _tmp5_;
		_g_free0 (_tmp4_);
		regex = _tmp6_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
		_tmp8_ = regex;
		_tmp9_ = g_regex_replace_literal (_tmp8_, self, (gssize) -1, 0, replacement, 0, &_inner_error0_);
		_tmp7_ = _tmp9_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_regex_unref0 (regex);
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			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_error0_;
		_inner_error0_ = NULL;
		g_assert_not_reached ();
		_g_error_free0 (e);
	}
	__finally0:
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
	g_clear_error (&_inner_error0_);
	return NULL;
}

gchar*
escape_filename (const gchar* filename)
{
	gchar* _tmp0_;
	gchar* result = NULL;
	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,
                  gint str_array_length1)
{
	gboolean _tmp0_ = FALSE;
	gchar* result = NULL;
	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 _tmp16_;
		gint _tmp17_;
		const gchar* res = NULL;
		void* _tmp18_;
		void* ptr = NULL;
		const gchar* _tmp19_;
		const gchar* _tmp20_;
		void* _tmp21_;
		const gchar* _tmp31_;
		len = (gsize) 1;
		{
			gboolean _tmp4_ = FALSE;
			i = 0;
			_tmp4_ = TRUE;
			while (TRUE) {
				gboolean _tmp6_ = FALSE;
				gboolean _tmp7_ = FALSE;
				gint _tmp10_ = 0;
				const gchar* _tmp11_;
				if (!_tmp4_) {
					gint _tmp5_;
					_tmp5_ = i;
					i = _tmp5_ + 1;
				}
				_tmp4_ = FALSE;
				if (str_array_length1 != -1) {
					_tmp7_ = i < str_array_length1;
				} else {
					_tmp7_ = FALSE;
				}
				if (_tmp7_) {
					_tmp6_ = TRUE;
				} else {
					gboolean _tmp8_ = FALSE;
					if (str_array_length1 == -1) {
						const gchar* _tmp9_;
						_tmp9_ = str_array[i];
						_tmp8_ = _tmp9_ != NULL;
					} else {
						_tmp8_ = FALSE;
					}
					_tmp6_ = _tmp8_;
				}
				if (!_tmp6_) {
					break;
				}
				_tmp11_ = str_array[i];
				if (_tmp11_ != NULL) {
					const gchar* _tmp12_;
					gint _tmp13_;
					gint _tmp14_;
					_tmp12_ = str_array[i];
					_tmp13_ = strlen ((const gchar*) _tmp12_);
					_tmp14_ = _tmp13_;
					_tmp10_ = _tmp14_;
				} else {
					_tmp10_ = 0;
				}
				len = len + _tmp10_;
			}
		}
		if (i == 0) {
			gchar* _tmp15_;
			_tmp15_ = g_strdup ("");
			result = _tmp15_;
			return result;
		}
		str_array_length1 = i;
		_tmp16_ = strlen ((const gchar*) separator);
		_tmp17_ = _tmp16_;
		len = len + (_tmp17_ * (i - 1));
		_tmp18_ = g_malloc (len);
		res = _tmp18_;
		_tmp19_ = res;
		_tmp20_ = str_array[0];
		_tmp21_ = g_stpcpy ((void*) _tmp19_, (const gchar*) _tmp20_);
		ptr = _tmp21_;
		{
			gboolean _tmp22_ = FALSE;
			i = 1;
			_tmp22_ = TRUE;
			while (TRUE) {
				void* _tmp24_;
				void* _tmp25_;
				const gchar* _tmp26_ = NULL;
				const gchar* _tmp27_;
				void* _tmp29_;
				void* _tmp30_;
				if (!_tmp22_) {
					gint _tmp23_;
					_tmp23_ = i;
					i = _tmp23_ + 1;
				}
				_tmp22_ = FALSE;
				if (!(i < str_array_length1)) {
					break;
				}
				_tmp24_ = ptr;
				_tmp25_ = g_stpcpy (_tmp24_, (const gchar*) separator);
				ptr = _tmp25_;
				_tmp27_ = str_array[i];
				if (_tmp27_ != NULL) {
					const gchar* _tmp28_;
					_tmp28_ = str_array[i];
					_tmp26_ = (const gchar*) _tmp28_;
				} else {
					_tmp26_ = "";
				}
				_tmp29_ = ptr;
				_tmp30_ = g_stpcpy (_tmp29_, _tmp26_);
				ptr = _tmp30_;
			}
		}
		_tmp31_ = res;
		res = NULL;
		result = (gchar*) _tmp31_;
		return result;
	} else {
		gchar* _tmp32_;
		_tmp32_ = g_strdup ("");
		result = _tmp32_;
		return result;
	}
}

static gchar*
string_slice (const gchar* self,
              glong start,
              glong end)
{
	glong string_length = 0L;
	gint _tmp0_;
	gint _tmp1_;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	gchar* _tmp4_;
	gchar* result = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = strlen (self);
	_tmp1_ = _tmp0_;
	string_length = (glong) _tmp1_;
	if (start < ((glong) 0)) {
		start = string_length + start;
	}
	if (end < ((glong) 0)) {
		end = string_length + end;
	}
	if (start >= ((glong) 0)) {
		_tmp2_ = start <= string_length;
	} else {
		_tmp2_ = FALSE;
	}
	g_return_val_if_fail (_tmp2_, NULL);
	if (end >= ((glong) 0)) {
		_tmp3_ = end <= string_length;
	} else {
		_tmp3_ = FALSE;
	}
	g_return_val_if_fail (_tmp3_, NULL);
	g_return_val_if_fail (start <= end, NULL);
	_tmp4_ = g_strndup (((gchar*) self) + start, (gsize) (end - start));
	result = _tmp4_;
	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,
            gint args_length1)
{
	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* _tmp140_;
	gchar* _tmp141_;
	gchar** _tmp142_;
	gint _tmp142__length1;
	FILE* _tmp150_;
	FILE* _tmp151_;
	const gchar* _tmp152_;
	FILE* _tmp166_;
	FILE* _tmp167_;
	FILE* _tmp168_;
	const gchar* _tmp169_;
	gchar* _tmp170_;
	gchar* _tmp171_;
	GError* _inner_error0_ = NULL;
	gint result = 0;
	_tmp0_ = _vala_g_strjoinv (" ", args, (gint) 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_, (gint*) (&args_length1), &args, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			gint _tmp7_ = -1;
			if (g_error_matches (_inner_error0_, G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE)) {
				goto __catch1_g_option_error_bad_value;
			}
			if (_inner_error0_->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_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return _tmp7_;
		}
	}
	goto __finally1;
	__catch1_g_option_error_bad_value:
	{
		GError* err = NULL;
		FILE* _tmp8_;
		GOptionContext* _tmp9_;
		gchar* _tmp10_;
		gchar* _tmp11_;
		err = _inner_error0_;
		_inner_error0_ = 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_error0_;
		_inner_error0_ = NULL;
		_tmp12_ = _error_;
		_tmp13_ = _tmp12_->message;
		g_warning ("wixl-heat.vala:50: %s", _tmp13_);
		_g_error_free0 (_error_);
	}
	__finally1:
	if (G_UNLIKELY (_inner_error0_ != 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_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		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;
			gchar* dir = NULL;
			gchar* _tmp56_;
			gchar** path = NULL;
			const gchar* _tmp57_;
			gchar** _tmp58_;
			gchar** _tmp59_;
			gint path_length1;
			gint _path_size_;
			gint i = 0;
			gchar** _tmp60_;
			gint _tmp60__length1;
			gchar** _tmp96_;
			gint _tmp96__length1;
			gchar** _tmp97_;
			gint _tmp97__length1;
			_tmp33_ = dis;
			_tmp34_ = g_data_input_stream_read_line (_tmp33_, NULL, NULL, &_inner_error0_);
			_tmp32_ = _tmp34_;
			if (G_UNLIKELY (_inner_error0_ != 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;
			if (is_directory) {
				const gchar* _tmp52_;
				gchar* _tmp53_;
				_tmp52_ = file;
				_tmp53_ = g_strdup (_tmp52_);
				_g_free0 (_tmp51_);
				_tmp51_ = _tmp53_;
			} else {
				const gchar* _tmp54_;
				gchar* _tmp55_;
				_tmp54_ = file;
				_tmp55_ = g_path_get_dirname (_tmp54_);
				_g_free0 (_tmp51_);
				_tmp51_ = _tmp55_;
			}
			_tmp56_ = g_strdup (_tmp51_);
			dir = _tmp56_;
			_tmp57_ = dir;
			_tmp59_ = _tmp58_ = g_strsplit (_tmp57_, G_DIR_SEPARATOR_S, -1);
			path = _tmp59_;
			path_length1 = _vala_array_length (_tmp58_);
			_path_size_ = path_length1;
			i = 0;
			_tmp60_ = last_path;
			_tmp60__length1 = last_path_length1;
			if (_tmp60_ != NULL) {
				while (TRUE) {
					gboolean _tmp61_ = FALSE;
					gboolean _tmp62_ = FALSE;
					gchar** _tmp63_;
					gint _tmp63__length1;
					const gchar* _tmp64_;
					gint _tmp71_;
					_tmp63_ = path;
					_tmp63__length1 = path_length1;
					_tmp64_ = _tmp63_[i];
					if (_tmp64_ != NULL) {
						gchar** _tmp65_;
						gint _tmp65__length1;
						const gchar* _tmp66_;
						_tmp65_ = last_path;
						_tmp65__length1 = last_path_length1;
						_tmp66_ = _tmp65_[i];
						_tmp62_ = _tmp66_ != NULL;
					} else {
						_tmp62_ = FALSE;
					}
					if (_tmp62_) {
						gchar** _tmp67_;
						gint _tmp67__length1;
						const gchar* _tmp68_;
						gchar** _tmp69_;
						gint _tmp69__length1;
						const gchar* _tmp70_;
						_tmp67_ = path;
						_tmp67__length1 = path_length1;
						_tmp68_ = _tmp67_[i];
						_tmp69_ = last_path;
						_tmp69__length1 = last_path_length1;
						_tmp70_ = _tmp69_[i];
						_tmp61_ = g_strcmp0 (_tmp68_, _tmp70_) == 0;
					} else {
						_tmp61_ = FALSE;
					}
					if (!_tmp61_) {
						break;
					}
					_tmp71_ = i;
					i = _tmp71_ + 1;
				}
				{
					gint j = 0;
					gchar** _tmp72_;
					gint _tmp72__length1;
					_tmp72_ = last_path;
					_tmp72__length1 = last_path_length1;
					j = _tmp72__length1 - i;
					{
						gboolean _tmp73_ = FALSE;
						_tmp73_ = TRUE;
						while (TRUE) {
							const gchar* _tmp75_;
							gchar* _tmp76_;
							FILE* _tmp77_;
							const gchar* _tmp78_;
							gchar* _tmp79_;
							gchar* _tmp80_;
							if (!_tmp73_) {
								gint _tmp74_;
								_tmp74_ = j;
								j = _tmp74_ - 1;
							}
							_tmp73_ = FALSE;
							if (!(j > 0)) {
								break;
							}
							_tmp75_ = indent;
							_tmp76_ = string_slice (_tmp75_, (glong) 0, (glong) -2);
							_g_free0 (indent);
							indent = _tmp76_;
							_tmp77_ = stdout;
							_tmp78_ = indent;
							_tmp79_ = g_strconcat (_tmp78_, "</Directory>\n", NULL);
							_tmp80_ = _tmp79_;
							fprintf (_tmp77_, "%s", _tmp80_);
							_g_free0 (_tmp80_);
						}
					}
				}
			}
			{
				gboolean _tmp81_ = FALSE;
				_tmp81_ = TRUE;
				while (TRUE) {
					gchar** _tmp83_;
					gint _tmp83__length1;
					FILE* _tmp84_;
					const gchar* _tmp85_;
					gchar* _tmp86_;
					gchar* _tmp87_;
					gchar** _tmp88_;
					gint _tmp88__length1;
					const gchar* _tmp89_;
					gchar* _tmp90_;
					gchar* _tmp91_;
					gchar* _tmp92_;
					gchar* _tmp93_;
					const gchar* _tmp94_;
					gchar* _tmp95_;
					if (!_tmp81_) {
						gint _tmp82_;
						_tmp82_ = i;
						i = _tmp82_ + 1;
					}
					_tmp81_ = FALSE;
					_tmp83_ = path;
					_tmp83__length1 = path_length1;
					if (!(i < _tmp83__length1)) {
						break;
					}
					_tmp84_ = stdout;
					_tmp85_ = indent;
					_tmp86_ = wixl_random_id ("dir");
					_tmp87_ = _tmp86_;
					_tmp88_ = path;
					_tmp88__length1 = path_length1;
					_tmp89_ = _tmp88_[i];
					_tmp90_ = g_strdup_printf ("<Directory Id=\"%s\" Name=\"%s\">\n", _tmp87_, _tmp89_);
					_tmp91_ = _tmp90_;
					_tmp92_ = g_strconcat (_tmp85_, _tmp91_, NULL);
					_tmp93_ = _tmp92_;
					fprintf (_tmp84_, "%s", _tmp93_);
					_g_free0 (_tmp93_);
					_g_free0 (_tmp91_);
					_g_free0 (_tmp87_);
					_tmp94_ = indent;
					_tmp95_ = g_strconcat (_tmp94_, "  ", NULL);
					_g_free0 (indent);
					indent = _tmp95_;
				}
			}
			_tmp96_ = path;
			_tmp96__length1 = path_length1;
			_tmp97_ = (_tmp96_ != NULL) ? _vala_array_dup1 (_tmp96_, _tmp96__length1) : ((gpointer) _tmp96_);
			_tmp97__length1 = _tmp96__length1;
			last_path = (_vala_array_free (last_path, last_path_length1, (GDestroyNotify) g_free), NULL);
			last_path = _tmp97_;
			last_path_length1 = _tmp97__length1;
			_last_path_size_ = last_path_length1;
			if (!is_directory) {
				gchar* id = NULL;
				const gchar* _tmp98_;
				gchar* _tmp99_;
				const gchar* _tmp100_;
				gchar* _tmp101_;
				const gchar* _tmp116_;
				gchar* _tmp117_;
				gchar* _tmp118_;
				const gchar* _tmp119_;
				gchar* _tmp120_;
				gchar* _tmp121_;
				gchar* _tmp122_;
				FILE* _tmp123_;
				const gchar* _tmp124_;
				const gchar* _tmp125_;
				gchar* _tmp126_;
				gchar* _tmp127_;
				const gchar* _tmp128_;
				gchar* _tmp129_;
				gchar* _tmp130_;
				gchar* _tmp131_;
				gchar* _tmp132_;
				FILE* _tmp133_;
				const gchar* _tmp134_;
				gchar* _tmp135_;
				gchar* _tmp136_;
				_tmp98_ = file;
				_tmp99_ = wixl_generate_id ("cmp", (guint) 1, _tmp98_, NULL);
				id = _tmp99_;
				_tmp100_ = id;
				_tmp101_ = g_strdup (_tmp100_);
				cmpref = g_list_append (cmpref, _tmp101_);
				if (win64) {
					FILE* _tmp102_;
					const gchar* _tmp103_;
					const gchar* _tmp104_;
					gchar* _tmp105_;
					gchar* _tmp106_;
					gchar* _tmp107_;
					gchar* _tmp108_;
					_tmp102_ = stdout;
					_tmp103_ = indent;
					_tmp104_ = id;
					_tmp105_ = g_strdup_printf ("<Component Win64=\"$(var.Win64)\" Id=\"%s\" Guid=\"*\">\n", _tmp104_);
					_tmp106_ = _tmp105_;
					_tmp107_ = g_strconcat (_tmp103_, _tmp106_, NULL);
					_tmp108_ = _tmp107_;
					fprintf (_tmp102_, "%s", _tmp108_);
					_g_free0 (_tmp108_);
					_g_free0 (_tmp106_);
				} else {
					FILE* _tmp109_;
					const gchar* _tmp110_;
					const gchar* _tmp111_;
					gchar* _tmp112_;
					gchar* _tmp113_;
					gchar* _tmp114_;
					gchar* _tmp115_;
					_tmp109_ = stdout;
					_tmp110_ = indent;
					_tmp111_ = id;
					_tmp112_ = g_strdup_printf ("<Component Id=\"%s\" Guid=\"*\">\n", _tmp111_);
					_tmp113_ = _tmp112_;
					_tmp114_ = g_strconcat (_tmp110_, _tmp113_, NULL);
					_tmp115_ = _tmp114_;
					fprintf (_tmp109_, "%s", _tmp115_);
					_g_free0 (_tmp115_);
					_g_free0 (_tmp113_);
				}
				_tmp116_ = sourcedir;
				_tmp117_ = g_strconcat (_tmp116_, G_DIR_SEPARATOR_S, NULL);
				_tmp118_ = _tmp117_;
				_tmp119_ = file;
				_tmp120_ = escape_filename (_tmp119_);
				_tmp121_ = _tmp120_;
				_tmp122_ = g_strconcat (_tmp118_, _tmp121_, NULL);
				_g_free0 (file);
				file = _tmp122_;
				_g_free0 (_tmp121_);
				_g_free0 (_tmp118_);
				_tmp123_ = stdout;
				_tmp124_ = indent;
				_tmp125_ = file;
				_tmp126_ = wixl_generate_id ("fil", (guint) 1, _tmp125_, NULL);
				_tmp127_ = _tmp126_;
				_tmp128_ = file;
				_tmp129_ = g_strdup_printf ("  <File Id=\"%s\" KeyPath=\"yes\" Source=\"%s\"/>\n", _tmp127_, _tmp128_);
				_tmp130_ = _tmp129_;
				_tmp131_ = g_strconcat (_tmp124_, _tmp130_, NULL);
				_tmp132_ = _tmp131_;
				fprintf (_tmp123_, "%s", _tmp132_);
				_g_free0 (_tmp132_);
				_g_free0 (_tmp130_);
				_g_free0 (_tmp127_);
				_tmp133_ = stdout;
				_tmp134_ = indent;
				_tmp135_ = g_strconcat (_tmp134_, "</Component>\n", NULL);
				_tmp136_ = _tmp135_;
				fprintf (_tmp133_, "%s", _tmp136_);
				_g_free0 (_tmp136_);
				_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* _tmp137_;
		const gchar* _tmp138_;
		_error_ = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp137_ = _error_;
		_tmp138_ = _tmp137_->message;
		g_warning ("wixl-heat.vala:115: %s", _tmp138_);
		_g_error_free0 (_error_);
	}
	__finally2:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gint _tmp139_ = -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_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return _tmp139_;
	}
	_tmp140_ = indent;
	_tmp141_ = string_slice (_tmp140_, (glong) 0, (glong) -2);
	_g_free0 (indent);
	indent = _tmp141_;
	_tmp142_ = last_path;
	_tmp142__length1 = last_path_length1;
	{
		gchar** l_collection = NULL;
		gint l_collection_length1 = 0;
		gint _l_collection_size_ = 0;
		gint l_it = 0;
		l_collection = _tmp142_;
		l_collection_length1 = _tmp142__length1;
		for (l_it = 0; l_it < l_collection_length1; l_it = l_it + 1) {
			gchar* _tmp143_;
			gchar* l = NULL;
			_tmp143_ = g_strdup (l_collection[l_it]);
			l = _tmp143_;
			{
				FILE* _tmp144_;
				const gchar* _tmp145_;
				gchar* _tmp146_;
				gchar* _tmp147_;
				const gchar* _tmp148_;
				gchar* _tmp149_;
				_tmp144_ = stdout;
				_tmp145_ = indent;
				_tmp146_ = g_strconcat (_tmp145_, "</Directory>\n", NULL);
				_tmp147_ = _tmp146_;
				fprintf (_tmp144_, "%s", _tmp147_);
				_g_free0 (_tmp147_);
				_tmp148_ = indent;
				_tmp149_ = string_slice (_tmp148_, (glong) 0, (glong) -2);
				_g_free0 (indent);
				indent = _tmp149_;
				_g_free0 (l);
			}
		}
	}
	_tmp150_ = stdout;
	fprintf (_tmp150_, "    </DirectoryRef>\n");
	_tmp151_ = stdout;
	fprintf (_tmp151_, "  </Fragment>\n");
	_tmp152_ = cg;
	if (_tmp152_ != NULL) {
		FILE* _tmp153_;
		FILE* _tmp154_;
		const gchar* _tmp155_;
		gchar* _tmp156_;
		gchar* _tmp157_;
		GList* _tmp158_;
		FILE* _tmp164_;
		FILE* _tmp165_;
		_tmp153_ = stdout;
		fprintf (_tmp153_, "  <Fragment>\n");
		_tmp154_ = stdout;
		_tmp155_ = cg;
		_tmp156_ = g_strdup_printf ("    <ComponentGroup Id=\"%s\">\n", _tmp155_);
		_tmp157_ = _tmp156_;
		fprintf (_tmp154_, "%s", _tmp157_);
		_g_free0 (_tmp157_);
		_tmp158_ = cmpref;
		{
			GList* id_collection = NULL;
			GList* id_it = NULL;
			id_collection = _tmp158_;
			for (id_it = id_collection; id_it != NULL; id_it = id_it->next) {
				gchar* _tmp159_;
				gchar* id = NULL;
				_tmp159_ = g_strdup ((const gchar*) id_it->data);
				id = _tmp159_;
				{
					FILE* _tmp160_;
					const gchar* _tmp161_;
					gchar* _tmp162_;
					gchar* _tmp163_;
					_tmp160_ = stdout;
					_tmp161_ = id;
					_tmp162_ = g_strdup_printf ("      <ComponentRef Id=\"%s\"/>\n", _tmp161_);
					_tmp163_ = _tmp162_;
					fprintf (_tmp160_, "%s", _tmp163_);
					_g_free0 (_tmp163_);
					_g_free0 (id);
				}
			}
		}
		_tmp164_ = stdout;
		fprintf (_tmp164_, "    </ComponentGroup>\n");
		_tmp165_ = stdout;
		fprintf (_tmp165_, "  </Fragment>\n");
	}
	_tmp166_ = stdout;
	fprintf (_tmp166_, "</Wix>\n");
	_tmp167_ = stdout;
	fprintf (_tmp167_, "<!-- generated with %s -->\n", PACKAGE_STRING);
	_tmp168_ = stdout;
	_tmp169_ = cmdline;
	_tmp170_ = string_replace (_tmp169_, "--", "-");
	_tmp171_ = _tmp170_;
	fprintf (_tmp168_, "<!-- %s -->\n", _tmp171_);
	_g_free0 (_tmp171_);
	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;
}

