comparison 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
comparison
equal deleted inserted replaced
932:988eff509920 933:8c5ba3e94e54
1605 !access_file(fd->path, W_OK)) 1605 !access_file(fd->path, W_OK))
1606 { 1606 {
1607 ret |= CHANGE_WARN_NO_WRITE_PERM; 1607 ret |= CHANGE_WARN_NO_WRITE_PERM;
1608 DEBUG_1("Change checked: no write permission: %s", fd->path); 1608 DEBUG_1("Change checked: no write permission: %s", fd->path);
1609 } 1609 }
1610 1610
1611 if (fd->change->dest && (strcmp(fd->path, fd->change->dest) == 0))
1612 {
1613 ret |= CHANGE_WARN_SAME;
1614 DEBUG_1("Change checked: source and destination is the same: %s", fd->path);
1615 }
1616
1617 if (fd->change->dest) 1611 if (fd->change->dest)
1618 { 1612 {
1613 const gchar *dest_ext = extension_from_path(fd->change->dest);
1614 if (!dest_ext) dest_ext = "";
1615
1616 if (strcasecmp(fd->extension, dest_ext) != 0)
1617 {
1618 ret |= CHANGE_WARN_CHANGED_EXT;
1619 DEBUG_1("Change checked: source and destination have different extensions: %s -> %s", fd->path, fd->change->dest);
1620 }
1621
1622 if (strcmp(fd->path, fd->change->dest) == 0)
1623 {
1624 ret |= CHANGE_WARN_SAME;
1625 DEBUG_1("Change checked: source and destination is the same: %s -> %s", fd->path, fd->change->dest);
1626 }
1627
1619 if (!isdir(dest_dir)) 1628 if (!isdir(dest_dir))
1620 { 1629 {
1621 ret |= CHANGE_NO_DEST_DIR; 1630 ret |= CHANGE_NO_DEST_DIR;
1622 DEBUG_1("Change checked: destination dir does not exist: %s -> %s", fd->path, fd->change->dest); 1631 DEBUG_1("Change checked: destination dir does not exist: %s -> %s", fd->path, fd->change->dest);
1623 } 1632 }
1726 if (error & CHANGE_WARN_DEST_EXISTS) 1735 if (error & CHANGE_WARN_DEST_EXISTS)
1727 { 1736 {
1728 if (result->len > 0) g_string_append(result, ", "); 1737 if (result->len > 0) g_string_append(result, ", ");
1729 g_string_append(result, _("destination already exists and will be overwritten")); 1738 g_string_append(result, _("destination already exists and will be overwritten"));
1730 } 1739 }
1731 1740
1732 if (error & CHANGE_WARN_SAME) 1741 if (error & CHANGE_WARN_SAME)
1733 { 1742 {
1734 if (result->len > 0) g_string_append(result, ", "); 1743 if (result->len > 0) g_string_append(result, ", ");
1735 g_string_append(result, _("source and destination is the same")); 1744 g_string_append(result, _("source and destination is the same"));
1745 }
1746
1747 if (error & CHANGE_WARN_CHANGED_EXT)
1748 {
1749 if (result->len > 0) g_string_append(result, ", ");
1750 g_string_append(result, _("source and destination have different extension"));
1736 } 1751 }
1737 1752
1738 return g_string_free(result, FALSE); 1753 return g_string_free(result, FALSE);
1739 } 1754 }
1740 1755