Ticket #2976: mc.viewer_magic-20130309.diff

File mc.viewer_magic-20130309.diff, 1.4 KB (added by szaszg, 11 years ago)
  • src/viewer/mcviewer.c

    diff --git a/src/viewer/mcviewer.c b/src/viewer/mcviewer.c
    index 93908f3..63b9313 100644
    a b mcview_load (mcview_t * view, const char *command, const char *file, int start_l 
    375375            if (view->magic_mode && (type != COMPRESSION_NONE)) 
    376376            { 
    377377                char *tmp_filename; 
     378                vfs_path_t *vpath1 = NULL; 
     379                int fd1; 
    378380 
    379                 vfs_path_free (view->filename_vpath); 
    380381                tmp_filename = g_strconcat (file, decompress_extension (type), (char *) NULL); 
    381                 view->filename_vpath = vfs_path_from_str (tmp_filename); 
     382                vpath1 = vfs_path_from_str (tmp_filename); 
     383                fd1 = mc_open (vpath1, O_RDONLY | O_NONBLOCK); 
     384                if (fd1 == -1) 
     385                { 
     386                    g_snprintf (tmp, sizeof (tmp), _("Cannot open \"%s\" in magic mode\n%s"), 
     387                                file, unix_error_string (errno)); 
     388                    mcview_show_error (view, tmp); 
     389                } 
     390                else 
     391                { 
     392                    mc_close (fd); 
     393                    fd = fd1; 
     394                    mc_fstat (fd, &st); 
     395                } 
     396                vfs_path_free (vpath1); 
     397 
    382398                g_free (tmp_filename); 
    383399            } 
    384400            mcview_set_datasource_file (view, fd, &st);