Index: trunk/src/plug_io.c =================================================================== --- trunk/src/plug_io.c (revision 23893) +++ trunk/src/plug_io.c (revision 23894) @@ -585,41 +585,6 @@ #define F2S(OBJ, TYPE) pcb_strflg_f2s((OBJ)->Flags, TYPE) -/* opens a file and check if it exists */ -FILE *pcb_check_and_open_file(const char *Filename, pcb_bool Confirm, pcb_bool AllButton, pcb_bool * WasAllButton, pcb_bool * WasCancelButton) -{ - FILE *fp = NULL; - struct stat buffer; - char message[PCB_PATH_MAX + 80]; - int response; - - if (Filename && *Filename) { - if (!stat(Filename, &buffer) && Confirm) { - const char *all_ok = "all ok"; - sprintf(message, "File '%s' exists, use anyway?", Filename); - if (WasAllButton) - *WasAllButton = pcb_false; - if (WasCancelButton) - *WasCancelButton = pcb_false; - if (!AllButton) - all_ok = NULL; - response = pcb_hid_message_box("warning", "Overwrite file", message, "cancel", 0, "ok", 1, all_ok, 2, NULL); - switch (response) { - case 2: - if (WasAllButton) - *WasAllButton = pcb_true; - break; - case 0: - if (WasCancelButton) - *WasCancelButton = pcb_true; - } - } - if ((fp = pcb_fopen(Filename, "w")) == NULL) - pcb_open_error_message(Filename); - } - return fp; -} - int pcb_save_buffer_elements(const char *Filename, const char *fmt) { int result; Index: trunk/src/plug_io.h =================================================================== --- trunk/src/plug_io.h (revision 23893) +++ trunk/src/plug_io.h (revision 23894) @@ -114,7 +114,6 @@ int pcb_write_font(pcb_font_t *Ptr, const char *Filename, const char *fmt); /********** common function used to be part of file.[ch] and friends **********/ -FILE *pcb_check_and_open_file(const char *, pcb_bool, pcb_bool, pcb_bool *, pcb_bool *); int pcb_save_pcb(const char *, const char *fmt); #define PCB_INHIBIT_BOARD_CHANGED 0x20 int pcb_load_pcb(const char *name, const char *fmt, pcb_bool, int how); /* how: 0=normal pcb; 1=default.pcb, 2=misc (do not load settings) | 0x10: ignore missing file, | PCB_INHIBIT_BOARD_CHANGED: do not send a board changed event */ Index: trunk/src_plugins/export_oldconn/oldconn.c =================================================================== --- trunk/src_plugins/export_oldconn/oldconn.c (revision 23893) +++ trunk/src_plugins/export_oldconn/oldconn.c (revision 23894) @@ -28,7 +28,10 @@ #include "conf_core.h" #include +#include +#include + #include "actions.h" #include "board.h" #include "data.h" @@ -36,6 +39,7 @@ #include "draw.h" #include "plugins.h" #include "plug_io.h" +#include "safe_fs.h" #include "find.h" #include "macro.h" #include "obj_subc_parent.h" @@ -232,7 +236,40 @@ pcb_redraw(); } +static FILE *pcb_check_and_open_file(const char *Filename, pcb_bool Confirm, pcb_bool AllButton, pcb_bool *WasAllButton, pcb_bool *WasCancelButton) +{ + FILE *fp = NULL; + struct stat buffer; + char message[PCB_PATH_MAX + 80]; + int response; + if (Filename && *Filename) { + if (!stat(Filename, &buffer) && Confirm) { + const char *all_ok = "all ok"; + sprintf(message, "File '%s' exists, use anyway?", Filename); + if (WasAllButton) + *WasAllButton = pcb_false; + if (WasCancelButton) + *WasCancelButton = pcb_false; + if (!AllButton) + all_ok = NULL; + response = pcb_hid_message_box("warning", "Overwrite file", message, "cancel", 0, "ok", 1, all_ok, 2, NULL); + switch (response) { + case 2: + if (WasAllButton) + *WasAllButton = pcb_true; + break; + case 0: + if (WasCancelButton) + *WasCancelButton = pcb_true; + } + } + if ((fp = pcb_fopen(Filename, "w")) == NULL) + pcb_open_error_message(Filename); + } + return fp; +} + static const char pcb_acts_ExportOldConn[] = "ExportOldConn(AllConnections|AllUnusedPins|ElementConnections,filename)\n"; static const char pcb_acth_ExportOldConn[] = "Export galvanic connection data in an old, custom file format."; /* DOC: exportoldconn.html */