Skip to content

Commit

Permalink
warn about changed file extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
nadvornik committed Jul 26, 2008
1 parent 4d67078 commit f7c504c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 16 deletions.
31 changes: 23 additions & 8 deletions src/filedata.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down
17 changes: 9 additions & 8 deletions src/typedefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit f7c504c

Please sign in to comment.