/* Check for file existence. If file already exists, ask for an action (skip, overwrite or rename). Return 0 if skipped. */ int tiemu_file_check(const char *src, char **dst) { int ret; char buffer[256]; char *dirname; *dst = NULL; if (1) { if (access(src, F_OK) == 0) { sprintf(buffer, _("The file %s already exists.\nOverwrite ?"), src); ret = msg_box3(_("Warning"), buffer, _("Overwrite "), _("Rename "), _("Skip ")); switch (ret) { case BUTTON1: *dst = g_strdup(src); return !0; break; case BUTTON2: dirname = msg_entry(_("Rename the file"), _("New name: "), src); if (dirname == NULL) return 0; *dst = g_strdup(dirname); g_free(dirname); return !0; break; case BUTTON3: return 0; break; default: return 0; break; } } else { *dst = g_strdup(src); return !0; } } else { *dst = g_strdup(src); return !0; } return !0; }
gint display_import_romversion_dbox(void) { const gchar *filename; char *dstname; int err; // get filename filename = create_fsel(inst_paths.base_dir, NULL, "*.rom;*.89u;*.9xu;*.v2u;*.tib", FALSE); if (!filename) return 0; if(ti68k_is_a_rom_file(filename)) { err = ti68k_convert_rom_to_image(filename, inst_paths.img_dir, &dstname); handle_error(); g_free(dstname); } else if(ti68k_is_a_tib_file(filename)) { IMG_INFO infos = { 0 }; int err = ti68k_get_tib_infos(filename, &infos, 0); int hw_type = HW2; if(infos.calc_type == TI92p || infos.calc_type == TI89) { int ret = msg_box3(_("HW type"), _("The FLASH upgrade can be imported as HW1 or HW2. Please choose..."), "HW1", "HW2", "Default"); if(ret == BUTTON1) hw_type = HW1; else if(ret == BUTTON2) hw_type = HW2; } // fake rom err = ti68k_convert_tib_to_image(filename, inst_paths.img_dir, &dstname, hw_type); handle_error(); g_free(dstname); } return 0; }
int import_romversion(const char *filename) { char *dstname; int err; if(ti68k_is_a_rom_file(filename)) { err = ti68k_convert_rom_to_image(filename, inst_paths.img_dir, &dstname); handle_error(); g_free(dstname); } else if(ti68k_is_a_tib_file(filename)) { #ifdef _MSC_VER IMG_INFO infos = {0}; #else IMG_INFO infos = {}; #endif int hw_type = HW2; err = ti68k_get_tib_infos(filename, &infos, 0); handle_error(); if (!err) { if(infos.calc_type == TI92p || infos.calc_type == TI89) { int ret = msg_box3(_("HW type"), _("The FLASH upgrade can be imported as HW1 or HW2. Please choose..."), "HW1", "HW2", "Default"); if(ret == BUTTON1) hw_type = HW1; else if(ret == BUTTON2) hw_type = HW2; } else if(infos.calc_type == TI89t) { int ret = msg_box3(_("HW type"), _("The FLASH upgrade can be imported as HW3 or HW4. Please choose..."), "HW3", "HW4", "Default"); hw_type = HW3; // default is HW3 for the Titanium, there's no Titanium HW2 if(ret == BUTTON1) hw_type = HW3; else if(ret == BUTTON2) hw_type = HW4; } } // fake rom err = ti68k_convert_tib_to_image(filename, inst_paths.img_dir, &dstname, hw_type); handle_error(); g_free(dstname); } else { msg_box1(_("Error"), _("This is not a valid file")); return -1; } return 0; }