예제 #1
0
파일: io_util.c 프로젝트: Df458/dfgame
char* load_resource_to_string(resource_pair)
{
    FILE* file = load_resource_file(resource_location, resource_name, "rb");
    fseek(file, 0, SEEK_END);
    size_t filesize = ftell(file) + 1;
    fseek(file, 0, SEEK_SET);
    char* filedata = calloc(filesize, sizeof(char));
    fread(filedata, 1, filesize, file);
    filedata[filesize - 1] = '\0';

    fclose(file);
    return filedata;
}
예제 #2
0
void TexturePackerView::on_button_browse_resource_file()
{
	clan::OpenFileDialog dlg(this);
	dlg.add_filter("Resource files", "*.xml", true);
	dlg.add_filter("All files", "*.*");

	dlg.set_initial_directory(clan::System::get_exe_path());

	if(dlg.show())
	{
		std::string filename = dlg.get_filename();

		try
		{
			load_resource_file(filename);
			lineedit_selected_resource_file->set_text(filename);
		}
		catch(clan::Exception error)
		{
			generation_result->set_text(clan::string_format("Error: %1", error.message));
		}
	}
}