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/ImageMetaData.cxx | 1 + src/gipfel.cxx | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/ImageMetaData.cxx b/src/ImageMetaData.cxx index e29bd03..06a16fa 100644 --- a/src/ImageMetaData.cxx +++ b/src/ImageMetaData.cxx @@ -257,6 +257,7 @@ ImageMetaData::save_image_jpgcom(char *in_img, char *out_img) { if (WEXITSTATUS(status) == 127 || WEXITSTATUS(status) == 126) fprintf(stderr, "%s not found\n", args[0]); } else { + perror("pexecvp"); err++; } 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