diff src/filedata.c @ 933:8c5ba3e94e54

warn about changed file extensions
author nadvornik
date Sat, 26 Jul 2008 19:01:20 +0000
parents ca07ab364c60
children 6aa60ae6f274
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);
 }