Index: trunk/src/plug_io.c =================================================================== --- trunk/src/plug_io.c (revision 27594) +++ trunk/src/plug_io.c (revision 27595) @@ -633,7 +633,7 @@ /* writes to pipe using the command defined by conf_core.rc.save_command %f are replaced by the passed filename */ -static int pcb_write_pipe(const char *Filename, pcb_bool thePcb, const char *fmt, pcb_bool subc_only, long subc_idx) +static int pcb_write_pipe(const char *Filename, pcb_bool thePcb, const char *fmt, pcb_bool subc_only, long subc_idx, int askovr) { FILE *fp; int result; @@ -642,7 +642,7 @@ const char *save_cmd; if (PCB_EMPTY_STRING_P(conf_core.rc.save_command)) - return pcb_write_pcb_file(Filename, thePcb, fmt, pcb_false, subc_only, subc_idx); + return pcb_write_pcb_file(Filename, thePcb, fmt, pcb_false, subc_only, subc_idx, askovr); save_cmd = conf_core.rc.save_command; /* setup commandline */ @@ -681,7 +681,7 @@ if (conf_core.editor.show_solder_side) pcb_buffers_flip_side(PCB); - result = pcb_write_pipe(Filename, pcb_false, fmt, pcb_true, subc_idx); + result = pcb_write_pipe(Filename, pcb_false, fmt, pcb_true, subc_idx, 1); if (conf_core.editor.show_solder_side) pcb_buffers_flip_side(PCB); return result; @@ -689,7 +689,7 @@ int pcb_save_buffer(const char *Filename, const char *fmt) { - return pcb_write_pipe(Filename, pcb_false, fmt, pcb_false, -1); + return pcb_write_pipe(Filename, pcb_false, fmt, pcb_false, -1, 1); } int pcb_save_pcb(const char *file, const char *fmt) @@ -700,7 +700,7 @@ if (conf_core.editor.io_incomp_popup) pcb_view_list_free_fields(&pcb_io_incompat_lst); - retcode = pcb_write_pipe(file, pcb_true, fmt, pcb_false, -1); + retcode = pcb_write_pipe(file, pcb_true, fmt, pcb_false, -1, 0); pcb_io_incompat_lst_enable = pcb_false; if (conf_core.editor.io_incomp_popup) { @@ -805,7 +805,7 @@ const char *fmt = conf_core.rc.emergency_format == NULL ? DEFAULT_EMERGENCY_FMT : conf_core.rc.emergency_format; sprintf(filename, conf_core.rc.emergency_name, (long int)pcb_getpid()); pcb_message(PCB_MSG_INFO, "Trying to save your layout in '%s'\n", filename); - pcb_write_pcb_file(filename, pcb_true, fmt, pcb_true, pcb_false, -1); + pcb_write_pcb_file(filename, pcb_true, fmt, pcb_true, pcb_false, -1, 0); } } @@ -876,19 +876,22 @@ fmt = conf_core.rc.backup_format; orig = PCB->Data->loader; - pcb_write_pcb_file(filename, pcb_true, fmt, pcb_true, pcb_false, -1); + pcb_write_pcb_file(filename, pcb_true, fmt, pcb_true, pcb_false, -1, 0); PCB->Data->loader = orig; free(filename); } -int pcb_write_pcb_file(const char *Filename, pcb_bool thePcb, const char *fmt, pcb_bool emergency, pcb_bool subc_only, long subc_idx) +int pcb_write_pcb_file(const char *Filename, pcb_bool thePcb, const char *fmt, pcb_bool emergency, pcb_bool subc_only, long subc_idx, int askovr) { FILE *fp; - int result, overwrite; + int result, overwrite = 0; char *fn_tmp = NULL; - overwrite = pcb_file_readable(Filename); + /* for askovr, do not make a backup copy - if the user explicitly says overwrite, just overwrite */ + if (!askovr) + overwrite = pcb_file_readable(Filename); + if (overwrite) { int len = strlen(Filename); fn_tmp = malloc(len+8); @@ -907,7 +910,12 @@ } } - if ((fp = pcb_fopen(&PCB->hidlib, Filename, "w")) == NULL) { + if (askovr) + fp = pcb_fopen_askovr(&PCB->hidlib, Filename, "w", NULL); + else + fp = pcb_fopen(&PCB->hidlib, Filename, "w"); + + if (fp == NULL) { pcb_open_error_message(Filename); return (-1); } Index: trunk/src/plug_io.h =================================================================== --- trunk/src/plug_io.h (revision 27594) +++ trunk/src/plug_io.h (revision 27595) @@ -144,7 +144,7 @@ int pcb_save_buffer(const char *Filename, const char *fmt); void pcb_print_quoted_string_(FILE *, const char *); /* without wrapping in "" */ void pcb_print_quoted_string(FILE *, const char *); /* with wrapping in "" */ -int pcb_write_pcb_file(const char *Filename, pcb_bool thePcb, const char *fmt, pcb_bool emergency, pcb_bool subc_only, long subc_idx); +int pcb_write_pcb_file(const char *Filename, pcb_bool thePcb, const char *fmt, pcb_bool emergency, pcb_bool subc_only, long subc_idx, int askovr); void pcb_set_design_dir(const char *fn); int pcb_load_buffer(pcb_hidlib_t *hidlib, pcb_buffer_t *buff, const char *fn, const char *fmt); Index: trunk/src_plugins/io_pcb/file.c =================================================================== --- trunk/src_plugins/io_pcb/file.c (revision 27594) +++ trunk/src_plugins/io_pcb/file.c (revision 27595) @@ -1193,7 +1193,7 @@ void pcb_tmp_data_save(void) { char *fn = pcb_build_fn(&PCB->hidlib, conf_core.rc.emergency_name); - pcb_write_pcb_file(fn, pcb_true, NULL, pcb_true, pcb_false, -1); + pcb_write_pcb_file(fn, pcb_true, NULL, pcb_true, pcb_false, -1, 0); if (TMPFilename != NULL) free(TMPFilename); TMPFilename = fn;