warn about changed file extensions
authorVladimir Nadvornik <nadvornik@suse.cz>
Sat, 26 Jul 2008 19:01:20 +0000 (19:01 +0000)
committerVladimir Nadvornik <nadvornik@suse.cz>
Sat, 26 Jul 2008 19:01:20 +0000 (19:01 +0000)
src/filedata.c
src/typedefs.h

index c14470e..d41a890 100644 (file)
@@ -1607,15 +1607,24 @@ gint file_data_verify_ci(FileData *fd)
                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 @@ gchar *file_data_get_error_string(gint error)
                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);
 }
 
index c8754ad..7581f33 100644 (file)
@@ -154,14 +154,15 @@ typedef enum {
        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;