From a7537a0f819198dcd6a6cb81887f6ca4d57dc24e Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Thu, 17 Jul 2008 21:25:02 +0200 Subject: add confirm_overwrite() --- src/gipfel.cxx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/gipfel.cxx') diff --git a/src/gipfel.cxx b/src/gipfel.cxx index 788d22b..b8c2fbe 100644 --- a/src/gipfel.cxx +++ b/src/gipfel.cxx @@ -9,6 +9,8 @@ #include #include #include +#include +#include #include #include @@ -64,6 +66,16 @@ static int stitch(GipfelWidget::sample_mode_t m , int b_16, static int export_hills(const char *export_file, double visibility); static int export_position(); +static int +confirm_overwrite(const char *f) { + struct stat sb; + + if (stat(f, &sb) == 0) + return fl_choice("The file exists.\n", "Cancel", "Overwrite", NULL); + else + return 1; +} + void set_values() { double k0 = 0.0, k1 = 0.0, x0 = 0.0; @@ -117,7 +129,7 @@ void track_cb() { void save_cb() { char *file = fl_file_chooser("Save Image As?", NULL, img_file); - if (file) + if (file && confirm_overwrite(file)) if (gipf->save_image(file)) fl_message("ERROR: Saving image %s failed.", file); } -- cgit v1.2.3