Merge branch '2976_broken_magic_mode'

* 2976_broken_magic_mode:
  Ticket #2976: magic mode is broken in mcview.
This commit is contained in:
Andrew Borodin 2013-03-20 17:02:44 +04:00
commit 68d5b0d610

View File

@ -375,10 +375,26 @@ mcview_load (mcview_t * view, const char *command, const char *file, int start_l
if (view->magic_mode && (type != COMPRESSION_NONE)) if (view->magic_mode && (type != COMPRESSION_NONE))
{ {
char *tmp_filename; char *tmp_filename;
vfs_path_t *vpath1;
int fd1;
vfs_path_free (view->filename_vpath);
tmp_filename = g_strconcat (file, decompress_extension (type), (char *) NULL); tmp_filename = g_strconcat (file, decompress_extension (type), (char *) NULL);
view->filename_vpath = vfs_path_from_str (tmp_filename); vpath1 = vfs_path_from_str (tmp_filename);
fd1 = mc_open (vpath1, O_RDONLY | O_NONBLOCK);
if (fd1 == -1)
{
g_snprintf (tmp, sizeof (tmp), _("Cannot open \"%s\" in magic mode\n%s"),
file, unix_error_string (errno));
mcview_show_error (view, tmp);
}
else
{
mc_close (fd);
fd = fd1;
mc_fstat (fd, &st);
}
vfs_path_free (vpath1);
g_free (tmp_filename); g_free (tmp_filename);
} }
mcview_set_datasource_file (view, fd, &st); mcview_set_datasource_file (view, fd, &st);