Skip to content

Commit

Permalink
Display error dialog with appropriate message when user is trying to …
Browse files Browse the repository at this point in the history
…open an invalid collection file.
  • Loading branch information
Laurent Monin committed Dec 8, 2008
1 parent 2d44c55 commit e5abe23
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/collect-dlg.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,33 @@ static void collection_save_cb(FileDialog *fd, gpointer data)
static void real_collection_button_pressed(FileDialog *fd, gpointer data, gint append)
{
CollectionData *cd = data;
gboolean err = FALSE;
gchar *text = NULL;

if (!fd->dest_path || isdir(fd->dest_path)) return;
if (!isname(fd->dest_path))
{
err = TRUE;
text = g_strdup_printf(_("No such file '%s'."), fd->dest_path);
}
if (!err && isdir(fd->dest_path))
{
err = TRUE;
text = g_strdup_printf(_("'%s' is a directory, not a collection file."), fd->dest_path);
}
if (!err && !access_file(fd->dest_path, R_OK))
{
err = TRUE;
text = g_strdup_printf(_("You do not have read permissions on the file '%s'."), fd->dest_path);
}

if (err) {
if (text)
{
file_util_warning_dialog(_("Can not open collection file"), text, GTK_STOCK_DIALOG_ERROR, NULL);
g_free(text);
}
return;
}

if (append)
{
Expand Down

0 comments on commit e5abe23

Please sign in to comment.