mirror of https://github.com/MidnightCommander/mc
Fixed creating string from relative non-local VFS.
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
parent
ecda2061f2
commit
88483f5fac
|
@ -639,7 +639,10 @@ vfs_path_to_str_flags (const vfs_path_t * vpath, int elements_count, vfs_path_fl
|
|||
url_str = vfs_path_build_url_params_str (element, !(flags & VPF_STRIP_PASSWORD));
|
||||
|
||||
if (*url_str != '\0')
|
||||
{
|
||||
g_string_append (buffer, url_str);
|
||||
g_string_append_c (buffer, PATH_SEP);
|
||||
}
|
||||
|
||||
g_free (url_str);
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ START_TEST (set_up_current_dir_url)
|
|||
test_subclass.flags = VFS_S_REMOTE;
|
||||
|
||||
cd_and_check ("/test://user:pass@host.net/path", "/test://user:pass@host.net/path");
|
||||
cd_and_check ("..", "/test://user:pass@host.net");
|
||||
cd_and_check ("..", "/test://user:pass@host.net/");
|
||||
|
||||
cd_and_check ("..", "/");
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ test_chdir (const vfs_path_t * vpath)
|
|||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
START_TEST (relative_cd)
|
||||
START_TEST (test_relative_cd)
|
||||
{
|
||||
vfs_path_t *vpath;
|
||||
|
||||
|
@ -102,11 +102,39 @@ START_TEST (relative_cd)
|
|||
fail_if (mc_chdir(vpath) == -1);
|
||||
vfs_path_free (vpath);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* Relative to panel_correct_path_to_show() */
|
||||
|
||||
START_TEST (test_vpath_to_str_filter)
|
||||
{
|
||||
vfs_path_t *vpath, *last_vpath;
|
||||
char *filtered_path;
|
||||
const vfs_path_element_t *path_element;
|
||||
|
||||
vpath = vfs_path_from_str ("/test1://some.host/dir");
|
||||
path_element = vfs_path_element_clone (vfs_path_get_by_index (vpath, -1));
|
||||
vfs_path_free (vpath);
|
||||
|
||||
last_vpath = vfs_path_new ();
|
||||
last_vpath->relative = TRUE;
|
||||
|
||||
vfs_path_add_element (last_vpath, path_element);
|
||||
|
||||
filtered_path = vfs_path_to_str_flags (last_vpath, 0,
|
||||
VPF_STRIP_HOME | VPF_STRIP_PASSWORD | VPF_HIDE_CHARSET);
|
||||
vfs_path_free (last_vpath);
|
||||
|
||||
fail_unless (strcmp("test1://some.host/dir", filtered_path) == 0, "actual: %s", filtered_path);
|
||||
g_free (filtered_path);
|
||||
|
||||
}
|
||||
END_TEST
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
|
@ -119,7 +147,8 @@ main (void)
|
|||
tcase_add_checked_fixture (tc_core, setup, teardown);
|
||||
|
||||
/* Add new tests here: *************** */
|
||||
tcase_add_test (tc_core, relative_cd);
|
||||
tcase_add_test (tc_core, test_relative_cd);
|
||||
tcase_add_test (tc_core, test_vpath_to_str_filter);
|
||||
/* *********************************** */
|
||||
|
||||
suite_add_tcase (s, tc_core);
|
||||
|
|
Loading…
Reference in New Issue