diff options
author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2008-07-17 21:25:02 +0200 |
---|---|---|
committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2008-07-17 21:25:02 +0200 |
commit | a7537a0f819198dcd6a6cb81887f6ca4d57dc24e (patch) | |
tree | 3336dccea1fc4dd6886dd749adf6fb45152a70ba /src | |
parent | 5408e20d80b87731e90840b5cc983a6717c851a5 (diff) |
add confirm_overwrite()
Diffstat (limited to 'src')
-rw-r--r-- | src/ImageMetaData.cxx | 1 | ||||
-rw-r--r-- | src/gipfel.cxx | 14 |
2 files changed, 14 insertions, 1 deletions
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 <unistd.h> #include <stdlib.h> #include <libgen.h> +#include <sys/types.h> +#include <sys/stat.h> #include <math.h> #include <algorithm> @@ -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); } |