void ui_open_datafile() { char *filename; filename = ask_filename(_("File to open: ")); if(!filename || ! *filename) { free(filename); refresh_screen(); return; } if(opt_get_bool(BOOL_AUTOSAVE)) save_database(); else if(statusline_ask_boolean(_("Save current database"), FALSE)) save_database(); close_database(); load_database(filename); if(list_is_empty()) { statusline_msg(_("Sorry, the specified file appears not to be a valid abook addressbook")); load_database(datafile); } else { free(datafile); datafile = xstrdup(filename); } refresh_screen(); free(filename); alternative_datafile = TRUE; }
void save_z80file() { unsigned char *videomem; int ancho,retorno; unsigned char nombre2[MAX_PATH_LENGTH]; char *name; videomem=screen->pixels; ancho=screen->w; clean_screen(); print_string(videomem,"Choose a name for the Z80 snapshot",-1,32,14,0,ancho); print_string(videomem,"(up to 30 characters)",-1,52,14,0,ancho); print_string(videomem,"Snapshot will be saved in:",-1,132,12,0,ancho); print_string(videomem,path_snaps,0,152,12,0,ancho); if (strlen(ordenador.current_tap)) { name=strrchr(ordenador.current_tap,'/'); if (name) name++; else name = ordenador.current_tap; } else name=NULL; retorno=ask_filename(nombre2,84,"z80", path_snaps, name); clean_screen(); if(retorno==2) // abort return; retorno=save_z80(nombre2,0); switch(retorno) { case 0: break; case -1: print_string(videomem,"File already exists",-1,80,10,0,ancho); wait_key(); break; case -2: print_string(videomem,"Can't create file",-1,80,10,0,ancho); wait_key(); break; } clean_screen(); }
static int snap(mmv_t *mmv, REP *first, REP *p) { char fname[PATH_MAX]; int redirected = 0; if (mmv->noex) { exit(1); } mmv->failed = 1; signal(SIGINT, breakstat); if (mmv->badstyle == ASKBAD && isatty(fileno(stdout)) && ask_yesno("Redirect standard output to file? ", 0)) { redirected = 1; umask(mmv->oldumask); while (true) { int err; mmv->outfile = ask_filename("File name> ", fname, sizeof (fname)); if (mmv->outfile != NULL) { break; } err = errno; eprint("open('"); eprint_filename(fname); eprint("') failed.\n"); eexplain_err(err); } } if (redirected || !mmv->verbose) { show_done_all(mmv, p); } fprintf(mmv->outfile, "The following left undone:\n"); mmv->noex = 1; return (first != p); }
void create_mdrfile() { unsigned char *videomem; int ancho,retorno,bucle,retval; unsigned char nombre2[MAX_PATH_LENGTH]; videomem=screen->pixels; ancho=screen->w; clean_screen(); print_string(videomem,"Choose a name for the MDR file",-1,32,14,0,ancho); print_string(videomem,"(up to 30 characters)",-1,52,14,0,ancho); print_string(videomem,"MDR file will be saved in:",-1,132,12,0,ancho); print_string(videomem,path_mdrs,0,152,12,0,ancho); retorno=ask_filename(nombre2,84,"mdr",path_mdrs, NULL); clean_screen(); if(retorno==2) // abort return; ordenador.mdr_file=fopen(nombre2,"r"); // test if it exists if(ordenador.mdr_file==NULL) retorno=0; else retorno=-1; if(!retorno) { ordenador.mdr_file=fopen(nombre2,"wb"); // create for write if(ordenador.mdr_file==NULL) retorno=-2; else { for(bucle=0;bucle<137921;bucle++) ordenador.mdr_cartridge[bucle]=0xFF; // erase cartridge ordenador.mdr_cartridge[137922]=0; retval=fwrite(ordenador.mdr_cartridge,137923,1,ordenador.mdr_file); // save cartridge fclose(ordenador.mdr_file); ordenador.mdr_file=NULL; ordenador.mdr_modified=0; retorno=0; } } strcpy(ordenador.mdr_current_mdr,nombre2); switch(retorno) { case 0: break; case -1: print_string(videomem,"File already exists",-1,80,10,0,ancho); ordenador.mdr_current_mdr[0]=0; wait_key(); break; case -2: print_string(videomem,"Can't create file",-1,80,10,0,ancho); ordenador.mdr_current_mdr[0]=0; wait_key(); break; } clean_screen(); }
void create_tapfile() { unsigned char *videomem; int ancho,retorno; unsigned char nombre2[MAX_PATH_LENGTH]; videomem=screen->pixels; ancho=screen->w; clean_screen(); print_string(videomem,"Choose a name for the TAP file",-1,32,14,0,ancho); print_string(videomem,"(up to 30 characters)",-1,52,14,0,ancho); print_string(videomem,"TAP file will be saved in:",-1,132,12,0,ancho); print_string(videomem,path_taps,0,152,12,0,ancho); retorno=ask_filename(nombre2,84,"tap",path_taps,NULL); clean_screen(); if(retorno==2) // abort return; if(ordenador.tap_file!=NULL) fclose(ordenador.tap_file); ordenador.tap_file=fopen(nombre2,"r"); // test if it exists if(ordenador.tap_file==NULL) retorno=0; else retorno=-1; if(!retorno) { ordenador.tap_file=fopen(nombre2,"a+b"); // create for read and write if(ordenador.tap_file==NULL) retorno=-2; else retorno=0; } ordenador.tape_write=1; // allow to write strcpy(ordenador.current_tap,nombre2); ordenador.tape_file_type = TAP_TAP; switch(retorno) { case 0: strcpy(ordenador.last_selected_file,nombre2); create_browser_tap(ordenador.tap_file); break; case -1: print_string(videomem,"File already exists",-1,80,10,0,ancho); ordenador.current_tap[0]=0; wait_key(); break; case -2: print_string(videomem,"Can't create file",-1,80,10,0,ancho); ordenador.current_tap[0]=0; wait_key(); break; } clean_screen(); }
void create_scrfile() { unsigned char *videomem; int ancho,retorno,retval; unsigned char nombre2[MAX_PATH_LENGTH]; FILE *fichero; char *name; videomem=screen->pixels; ancho=screen->w; clean_screen(); print_string(videomem,"Choose a name for the SCR file",-1,32,14,0,ancho); print_string(videomem,"(up to 30 characters)",-1,52,14,0,ancho); print_string(videomem,"SCR file will be saved in:",-1,132,12,0,ancho); print_string(videomem,path_scr1,0,152,12,0,ancho); if (strlen(ordenador.current_tap)) { name=strrchr(ordenador.current_tap,'/'); if (name) name++; else name = ordenador.current_tap; } else name=NULL; retorno=ask_filename(nombre2,84,"scr",path_scr1, name); clean_screen(); if(retorno==2) // abort return; fichero=fopen(nombre2,"r"); // test if it exists if(fichero==NULL) retorno=0; else { fclose(fichero); retorno=-1; } if(!retorno) { fichero=fopen(nombre2,"wb"); // create for write if(fichero==NULL) retorno=-2; else { retval=fwrite(ordenador.block1+0x04000,6912,1,fichero); // save screen if (ordenador.ulaplus!=0) { retval=fwrite(ordenador.ulaplus_palete,64,1,fichero); // save ULAPlus palete } fclose(fichero); retorno=0; } } switch(retorno) { case -1: print_string(videomem,"File already exists",-1,80,10,0,ancho); wait_key(); break; case -2: print_string(videomem,"Can't create file",-1,80,10,0,ancho); wait_key(); break; default: break; } clean_screen(); }