mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 04:46:55 +03:00
Ticket #2976: magic mode is broken in mcview.
The bug: If we open a file with F3 from panels, then mc uses "file extension" style open (e.g. archive.sh) and Format/Raw switching is O.K. If we open file in "Raw" mode, or use quick view, mc opens files without "file extension" helpers. Format/Raw switching is broken. In mcview_load() we check magic_mode and detect "compressed" files. If magic mode is on and file is "compressed" we free the current vpath and generate a new vpath with "decompress magic", but nothing else. So, the file name disappear and we see the raw content. After user press F8, mcview reloads the file. Now filename is the "new" magic filename. mcview_load() open the file with the decompress "helper" (using sfs). We see the uncompressed (parsed) content. After user press F8, nothing happend, because original file name is lost. The solution: Remove the old vpath destruction. Open the file with "uncopress magic" if magic_mode is on and file is "compressed". Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
51a6273fb8
commit
b8208b0514
@ -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))
|
||||
{
|
||||
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);
|
||||
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);
|
||||
}
|
||||
mcview_set_datasource_file (view, fd, &st);
|
||||
|
Loading…
Reference in New Issue
Block a user