Mercurial > geeqie
changeset 933:8c5ba3e94e54
warn about changed file extensions
author | nadvornik |
---|---|
date | Sat, 26 Jul 2008 19:01:20 +0000 |
parents | 988eff509920 |
children | 6aa60ae6f274 |
files | src/filedata.c src/typedefs.h |
diffstat | 2 files changed, 32 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/src/filedata.c Sat Jul 26 18:33:49 2008 +0000 +++ b/src/filedata.c Sat Jul 26 19:01:20 2008 +0000 @@ -1607,15 +1607,24 @@ ret |= CHANGE_WARN_NO_WRITE_PERM; DEBUG_1("Change checked: no write permission: %s", fd->path); } - - if (fd->change->dest && (strcmp(fd->path, fd->change->dest) == 0)) - { - ret |= CHANGE_WARN_SAME; - DEBUG_1("Change checked: source and destination is the same: %s", fd->path); - } - + if (fd->change->dest) { + const gchar *dest_ext = extension_from_path(fd->change->dest); + if (!dest_ext) dest_ext = ""; + + if (strcasecmp(fd->extension, dest_ext) != 0) + { + ret |= CHANGE_WARN_CHANGED_EXT; + DEBUG_1("Change checked: source and destination have different extensions: %s -> %s", fd->path, fd->change->dest); + } + + if (strcmp(fd->path, fd->change->dest) == 0) + { + ret |= CHANGE_WARN_SAME; + DEBUG_1("Change checked: source and destination is the same: %s -> %s", fd->path, fd->change->dest); + } + if (!isdir(dest_dir)) { ret |= CHANGE_NO_DEST_DIR; @@ -1728,13 +1737,19 @@ if (result->len > 0) g_string_append(result, ", "); g_string_append(result, _("destination already exists and will be overwritten")); } - + if (error & CHANGE_WARN_SAME) { if (result->len > 0) g_string_append(result, ", "); g_string_append(result, _("source and destination is the same")); } + if (error & CHANGE_WARN_CHANGED_EXT) + { + if (result->len > 0) g_string_append(result, ", "); + g_string_append(result, _("source and destination have different extension")); + } + return g_string_free(result, FALSE); }
--- a/src/typedefs.h Sat Jul 26 18:33:49 2008 +0000 +++ b/src/typedefs.h Sat Jul 26 19:01:20 2008 +0000 @@ -154,14 +154,15 @@ CHANGE_WARN_DEST_EXISTS = 1 << 0, CHANGE_WARN_NO_WRITE_PERM = 1 << 1, CHANGE_WARN_SAME = 1 << 2, - CHANGE_ERROR_MASK = (~0) << 3, /* the values below are fatal errors */ - CHANGE_NO_READ_PERM = 1 << 3, - CHANGE_NO_WRITE_PERM_DIR = 1 << 4, - CHANGE_NO_DEST_DIR = 1 << 5, - CHANGE_NO_WRITE_PERM_DEST_DIR = 1 << 6, - CHANGE_NO_WRITE_PERM_DEST = 1 << 7, - CHANGE_DEST_EXISTS = 1 << 8, - CHANGE_NO_SRC = 1 << 9, + CHANGE_WARN_CHANGED_EXT = 1 << 3, + CHANGE_ERROR_MASK = (~0) << 4, /* the values below are fatal errors */ + CHANGE_NO_READ_PERM = 1 << 4, + CHANGE_NO_WRITE_PERM_DIR = 1 << 5, + CHANGE_NO_DEST_DIR = 1 << 6, + CHANGE_NO_WRITE_PERM_DEST_DIR = 1 << 7, + CHANGE_NO_WRITE_PERM_DEST = 1 << 8, + CHANGE_DEST_EXISTS = 1 << 9, + CHANGE_NO_SRC = 1 << 10, CHANGE_GENERIC_ERROR = 1 << 16 } ChangeError;