mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
Fix panel recoding
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
parent
1687b7cf96
commit
857fe38e87
@ -1033,6 +1033,39 @@ vfs_path_element_need_cleanup_converter (const vfs_path_element_t * element)
|
||||
{
|
||||
return (element->dir.converter != str_cnv_from_term && element->dir.converter != INVALID_CONV);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Change encoding for last part (vfs_path_element_t) of vpath
|
||||
*
|
||||
* @param vpath pointer to path structure
|
||||
* encoding name of charset
|
||||
*
|
||||
* @return pointer to path structure (for use function in anoter functions)
|
||||
*/
|
||||
vfs_path_t *
|
||||
vfs_path_change_encoding (vfs_path_t * vpath, const char *encoding)
|
||||
{
|
||||
vfs_path_element_t *path_element;
|
||||
|
||||
path_element = (vfs_path_element_t *) vfs_path_get_by_index (vpath, -1);
|
||||
/* don't add current encoding */
|
||||
if ((path_element->encoding != NULL) && (strcmp (encoding, path_element->encoding) == 0))
|
||||
return vpath;
|
||||
|
||||
g_free (path_element->encoding);
|
||||
path_element->encoding = g_strdup (encoding);
|
||||
|
||||
if (vfs_path_element_need_cleanup_converter (path_element))
|
||||
str_close_conv (path_element->dir.converter);
|
||||
|
||||
path_element->dir.converter = str_crt_conv_from (path_element->encoding);
|
||||
|
||||
g_free (vpath->str);
|
||||
vpath->str = vfs_path_to_str_flags (vpath, 0, VPF_NONE);
|
||||
return vpath;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -83,6 +83,7 @@ struct vfs_class *vfs_prefix_to_class (const char *prefix);
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
gboolean vfs_path_element_need_cleanup_converter (const vfs_path_element_t * element);
|
||||
vfs_path_t *vfs_path_change_encoding (vfs_path_t * vpath, const char *encoding);
|
||||
#endif
|
||||
|
||||
char *vfs_path_serialize (const vfs_path_t * vpath, GError ** error);
|
||||
|
@ -588,40 +588,6 @@ _vfs_get_cwd (void)
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
/**
|
||||
* Change encoding for last part (vfs_path_element_t) of vpath
|
||||
*
|
||||
* @param vpath pointer to path structure
|
||||
* encoding name of charset
|
||||
*
|
||||
* @return pointer to path structure (for use function in anoter functions)
|
||||
*/
|
||||
vfs_path_t *
|
||||
vfs_change_encoding (vfs_path_t * vpath, const char *encoding)
|
||||
{
|
||||
vfs_path_element_t *path_element;
|
||||
|
||||
path_element = (vfs_path_element_t *) vfs_path_get_by_index (vpath, -1);
|
||||
/* don't add current encoding */
|
||||
if ((path_element->encoding != NULL) && (strcmp (encoding, path_element->encoding) == 0))
|
||||
return vpath;
|
||||
|
||||
g_free (path_element->encoding);
|
||||
path_element->encoding = g_strdup (encoding);
|
||||
|
||||
if (vfs_path_element_need_cleanup_converter (path_element))
|
||||
str_close_conv (path_element->dir.converter);
|
||||
|
||||
path_element->dir.converter = str_crt_conv_from (path_element->encoding);
|
||||
|
||||
return vpath;
|
||||
}
|
||||
#endif /* HAVE_CHARSET */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Preallocate space for file in new place for ensure that file
|
||||
* will be fully copied with less fragmentation.
|
||||
|
@ -272,10 +272,6 @@ void vfs_free_handle (int handle);
|
||||
void vfs_setup_cwd (void);
|
||||
char *_vfs_get_cwd (void);
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
vfs_path_t *vfs_change_encoding (vfs_path_t * vpath, const char *encoding);
|
||||
#endif
|
||||
|
||||
int vfs_preallocate (int dest_desc, off_t src_fsize, off_t dest_fsize);
|
||||
|
||||
/**
|
||||
|
@ -4535,7 +4535,7 @@ panel_change_encoding (WPanel * panel)
|
||||
encoding = get_codepage_id (panel->codepage);
|
||||
if (encoding != NULL)
|
||||
{
|
||||
vfs_change_encoding (panel->cwd_vpath, encoding);
|
||||
vfs_path_change_encoding (panel->cwd_vpath, encoding);
|
||||
|
||||
if (!do_panel_cd (panel, panel->cwd_vpath, cd_parse_command))
|
||||
message (D_ERROR, MSG_ERROR, _("Cannot chdir to \"%s\""),
|
||||
@ -4566,14 +4566,19 @@ remove_encoding_from_path (const vfs_path_t * vpath)
|
||||
vfs_path_element_t *path_element;
|
||||
|
||||
path_element = vfs_path_element_clone (vfs_path_get_by_index (vpath, indx));
|
||||
vfs_path_add_element (ret_vpath, path_element);
|
||||
|
||||
if (path_element->encoding == NULL)
|
||||
{
|
||||
vfs_path_add_element (ret_vpath, path_element);
|
||||
continue;
|
||||
}
|
||||
|
||||
converter = str_crt_conv_to (path_element->encoding);
|
||||
if (converter == INVALID_CONV)
|
||||
{
|
||||
vfs_path_add_element (ret_vpath, path_element);
|
||||
continue;
|
||||
}
|
||||
|
||||
g_free (path_element->encoding);
|
||||
path_element->encoding = NULL;
|
||||
@ -4588,6 +4593,7 @@ remove_encoding_from_path (const vfs_path_t * vpath)
|
||||
str_close_conv (converter);
|
||||
str_close_conv (path_element->dir.converter);
|
||||
path_element->dir.converter = INVALID_CONV;
|
||||
vfs_path_add_element (ret_vpath, path_element);
|
||||
}
|
||||
g_string_free (tmp_conv, TRUE);
|
||||
return ret_vpath;
|
||||
|
Loading…
Reference in New Issue
Block a user