Reorder VFS parser to work with VFS parameters:
* Removed vfs_path_element_t->raw_url_str; * Changed some VFS prefixes (colon now used when need to split VFS prefix and VFS parameters); * Removed vfs_translate_url() functions and related code; * added converter of VFS parameters to string representation. Signed-off-by: Slava Zanko <slavazanko@gmail.com>
Этот коммит содержится в:
родитель
bd022573e5
Коммит
39462b9b76
@ -80,14 +80,14 @@ START_TEST (set_up_current_dir)
|
|||||||
|
|
||||||
vfs_test_ops.name = "testfs";
|
vfs_test_ops.name = "testfs";
|
||||||
vfs_test_ops.flags = VFSF_NOLINKS;
|
vfs_test_ops.flags = VFSF_NOLINKS;
|
||||||
vfs_test_ops.prefix = "test:";
|
vfs_test_ops.prefix = "test";
|
||||||
vfs_test_ops.chdir = test_chdir;
|
vfs_test_ops.chdir = test_chdir;
|
||||||
|
|
||||||
vfs_register_class (&vfs_test_ops);
|
vfs_register_class (&vfs_test_ops);
|
||||||
|
|
||||||
cd_and_check ("/dev/some.file#test:/bla-bla", "/dev/some.file#test:/bla-bla");
|
cd_and_check ("/dev/some.file#test/bla-bla", "/dev/some.file#test/bla-bla");
|
||||||
|
|
||||||
cd_and_check ("..", "/dev/some.file#test:");
|
cd_and_check ("..", "/dev/some.file#test");
|
||||||
|
|
||||||
cd_and_check ("..", "/dev");
|
cd_and_check ("..", "/dev");
|
||||||
|
|
||||||
@ -95,9 +95,9 @@ START_TEST (set_up_current_dir)
|
|||||||
|
|
||||||
cd_and_check ("..", "/");
|
cd_and_check ("..", "/");
|
||||||
|
|
||||||
cd_and_check ("/dev/some.file/#test:/bla-bla", "/dev/some.file/#test:/bla-bla");
|
cd_and_check ("/dev/some.file/#test/bla-bla", "/dev/some.file/#test/bla-bla");
|
||||||
|
|
||||||
cd_and_check ("..", "/dev/some.file/#test:");
|
cd_and_check ("..", "/dev/some.file/#test");
|
||||||
|
|
||||||
cd_and_check ("..", "/dev");
|
cd_and_check ("..", "/dev");
|
||||||
|
|
||||||
|
@ -58,17 +58,17 @@ setup (void)
|
|||||||
|
|
||||||
vfs_test_ops1.name = "testfs1";
|
vfs_test_ops1.name = "testfs1";
|
||||||
vfs_test_ops1.flags = VFSF_NOLINKS;
|
vfs_test_ops1.flags = VFSF_NOLINKS;
|
||||||
vfs_test_ops1.prefix = "test1:";
|
vfs_test_ops1.prefix = "test1";
|
||||||
vfs_register_class (&vfs_test_ops1);
|
vfs_register_class (&vfs_test_ops1);
|
||||||
|
|
||||||
vfs_s_init_class (&vfs_test_ops2, &test_subclass2);
|
vfs_s_init_class (&vfs_test_ops2, &test_subclass2);
|
||||||
vfs_test_ops2.name = "testfs2";
|
vfs_test_ops2.name = "testfs2";
|
||||||
vfs_test_ops2.prefix = "test2:";
|
vfs_test_ops2.prefix = "test2";
|
||||||
vfs_register_class (&vfs_test_ops2);
|
vfs_register_class (&vfs_test_ops2);
|
||||||
|
|
||||||
vfs_s_init_class (&vfs_test_ops3, &test_subclass3);
|
vfs_s_init_class (&vfs_test_ops3, &test_subclass3);
|
||||||
vfs_test_ops3.name = "testfs3";
|
vfs_test_ops3.name = "testfs3";
|
||||||
vfs_test_ops3.prefix = "test3:";
|
vfs_test_ops3.prefix = "test3";
|
||||||
vfs_register_class (&vfs_test_ops3);
|
vfs_register_class (&vfs_test_ops3);
|
||||||
|
|
||||||
mc_global.sysconfig_dir = (char *) TEST_SHARE_DIR;
|
mc_global.sysconfig_dir = (char *) TEST_SHARE_DIR;
|
||||||
@ -85,7 +85,7 @@ teardown (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
#define ETALON_PATH_STR "/local/path/#test1:user:pass@some.host:12345/bla-bla/some/path/#test2:/#enc:KOI8-R/bla-bla/some/path#test3:/111/22/33"
|
#define ETALON_PATH_STR "/local/path/#test1:user:pass@some.host:12345/bla-bla/some/path/#test2/#enc:KOI8-R/bla-bla/some/path#test3/111/22/33"
|
||||||
#define ETALON_SERIALIZED_PATH \
|
#define ETALON_SERIALIZED_PATH \
|
||||||
"g14:path-element-0" \
|
"g14:path-element-0" \
|
||||||
"p4:pathv12:/local/path/" \
|
"p4:pathv12:/local/path/" \
|
||||||
@ -93,7 +93,6 @@ teardown (void)
|
|||||||
"g14:path-element-1" \
|
"g14:path-element-1" \
|
||||||
"p4:pathv18:bla-bla/some/path/" \
|
"p4:pathv18:bla-bla/some/path/" \
|
||||||
"p10:class-namev7:testfs1" \
|
"p10:class-namev7:testfs1" \
|
||||||
"p11:raw_url_strv31:test1:user:pass@some.host:12345" \
|
|
||||||
"p10:vfs_prefixv5:test1" \
|
"p10:vfs_prefixv5:test1" \
|
||||||
"p4:userv4:user" \
|
"p4:userv4:user" \
|
||||||
"p8:passwordv4:pass" \
|
"p8:passwordv4:pass" \
|
||||||
@ -103,15 +102,11 @@ teardown (void)
|
|||||||
"p4:pathv17:bla-bla/some/path" \
|
"p4:pathv17:bla-bla/some/path" \
|
||||||
"p10:class-namev7:testfs2" \
|
"p10:class-namev7:testfs2" \
|
||||||
"p8:encodingv6:KOI8-R" \
|
"p8:encodingv6:KOI8-R" \
|
||||||
"p11:raw_url_strv6:test2:" \
|
|
||||||
"p10:vfs_prefixv5:test2" \
|
"p10:vfs_prefixv5:test2" \
|
||||||
"p4:hostv0:" \
|
|
||||||
"g14:path-element-3" \
|
"g14:path-element-3" \
|
||||||
"p4:pathv9:111/22/33" \
|
"p4:pathv9:111/22/33" \
|
||||||
"p10:class-namev7:testfs3" \
|
"p10:class-namev7:testfs3" \
|
||||||
"p11:raw_url_strv6:test3:" \
|
"p10:vfs_prefixv5:test3"
|
||||||
"p10:vfs_prefixv5:test3" \
|
|
||||||
"p4:hostv0:"
|
|
||||||
|
|
||||||
START_TEST (test_path_serialize_deserialize)
|
START_TEST (test_path_serialize_deserialize)
|
||||||
{
|
{
|
||||||
|
@ -57,17 +57,17 @@ setup (void)
|
|||||||
|
|
||||||
vfs_test_ops1.name = "testfs1";
|
vfs_test_ops1.name = "testfs1";
|
||||||
vfs_test_ops1.flags = VFSF_NOLINKS;
|
vfs_test_ops1.flags = VFSF_NOLINKS;
|
||||||
vfs_test_ops1.prefix = "test1:";
|
vfs_test_ops1.prefix = "test1";
|
||||||
vfs_register_class (&vfs_test_ops1);
|
vfs_register_class (&vfs_test_ops1);
|
||||||
|
|
||||||
vfs_s_init_class (&vfs_test_ops2, &test_subclass2);
|
vfs_s_init_class (&vfs_test_ops2, &test_subclass2);
|
||||||
vfs_test_ops2.name = "testfs2";
|
vfs_test_ops2.name = "testfs2";
|
||||||
vfs_test_ops2.prefix = "test2:";
|
vfs_test_ops2.prefix = "test2";
|
||||||
vfs_register_class (&vfs_test_ops2);
|
vfs_register_class (&vfs_test_ops2);
|
||||||
|
|
||||||
vfs_s_init_class (&vfs_test_ops3, &test_subclass3);
|
vfs_s_init_class (&vfs_test_ops3, &test_subclass3);
|
||||||
vfs_test_ops3.name = "testfs3";
|
vfs_test_ops3.name = "testfs3";
|
||||||
vfs_test_ops3.prefix = "test3:";
|
vfs_test_ops3.prefix = "test3";
|
||||||
vfs_register_class (&vfs_test_ops3);
|
vfs_register_class (&vfs_test_ops3);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -80,7 +80,7 @@ teardown (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
#define ETALON_PATH_STR "/#test1:/bla-bla/some/path/#test2:/bla-bla/some/path#test3:/111/22/33"
|
#define ETALON_PATH_STR "/#test1/bla-bla/some/path/#test2/bla-bla/some/path#test3/111/22/33"
|
||||||
START_TEST (test_vfs_path_from_to_string)
|
START_TEST (test_vfs_path_from_to_string)
|
||||||
{
|
{
|
||||||
vfs_path_t *vpath;
|
vfs_path_t *vpath;
|
||||||
@ -137,14 +137,14 @@ START_TEST (test_vfs_path_from_to_partial_string_by_class)
|
|||||||
|
|
||||||
result = vfs_path_to_str_elements_count(vpath, -1);
|
result = vfs_path_to_str_elements_count(vpath, -1);
|
||||||
fail_unless(
|
fail_unless(
|
||||||
strcmp("/#test1:/bla-bla/some/path/#test2:/bla-bla/some/path", result) == 0,
|
strcmp("/#test1/bla-bla/some/path/#test2/bla-bla/some/path", result) == 0,
|
||||||
"expected(%s) doesn't equal to actual(%s)", "/#test1:/bla-bla/some/path/#test2:/bla-bla/some/path", result);
|
"expected(%s) doesn't equal to actual(%s)", "/#test1/bla-bla/some/path/#test2/bla-bla/some/path", result);
|
||||||
g_free(result);
|
g_free(result);
|
||||||
|
|
||||||
result = vfs_path_to_str_elements_count(vpath, -2);
|
result = vfs_path_to_str_elements_count(vpath, -2);
|
||||||
fail_unless(
|
fail_unless(
|
||||||
strcmp("/#test1:/bla-bla/some/path/", result) == 0,
|
strcmp("/#test1/bla-bla/some/path/", result) == 0,
|
||||||
"expected(%s) doesn't equal to actual(%s)", "/#test1:/bla-bla/some/path/", result);
|
"expected(%s) doesn't equal to actual(%s)", "/#test1/bla-bla/some/path/", result);
|
||||||
g_free(result);
|
g_free(result);
|
||||||
|
|
||||||
result = vfs_path_to_str_elements_count(vpath, -3);
|
result = vfs_path_to_str_elements_count(vpath, -3);
|
||||||
@ -169,14 +169,14 @@ START_TEST (test_vfs_path_from_to_partial_string_by_class)
|
|||||||
|
|
||||||
result = vfs_path_to_str_elements_count(vpath, 2);
|
result = vfs_path_to_str_elements_count(vpath, 2);
|
||||||
fail_unless(
|
fail_unless(
|
||||||
strcmp("/#test1:/bla-bla/some/path/", result) == 0,
|
strcmp("/#test1/bla-bla/some/path/", result) == 0,
|
||||||
"expected(%s) doesn't equal to actual(%s)", "/#test1:/bla-bla/some/path/", result);
|
"expected(%s) doesn't equal to actual(%s)", "/#test1/bla-bla/some/path/", result);
|
||||||
g_free(result);
|
g_free(result);
|
||||||
|
|
||||||
result = vfs_path_to_str_elements_count(vpath, 3);
|
result = vfs_path_to_str_elements_count(vpath, 3);
|
||||||
fail_unless(
|
fail_unless(
|
||||||
strcmp("/#test1:/bla-bla/some/path/#test2:/bla-bla/some/path", result) == 0,
|
strcmp("/#test1/bla-bla/some/path/#test2/bla-bla/some/path", result) == 0,
|
||||||
"expected(%s) doesn't equal to actual(%s)", "/#test1:/bla-bla/some/path/#test2:/bla-bla/some/path", result);
|
"expected(%s) doesn't equal to actual(%s)", "/#test1/bla-bla/some/path/#test2/bla-bla/some/path", result);
|
||||||
g_free(result);
|
g_free(result);
|
||||||
|
|
||||||
result = vfs_path_to_str_elements_count(vpath, 4);
|
result = vfs_path_to_str_elements_count(vpath, 4);
|
||||||
@ -217,33 +217,33 @@ START_TEST (test_vfs_path_from_to_string_encoding)
|
|||||||
load_codepages_list ();
|
load_codepages_list ();
|
||||||
|
|
||||||
encoding_check (
|
encoding_check (
|
||||||
"/#test1:/bla-bla1/some/path/#test2:/bla-bla2/#enc:KOI8-R/some/path#test3:/111/22/33",
|
"/#test1/bla-bla1/some/path/#test2/bla-bla2/#enc:KOI8-R/some/path#test3/111/22/33",
|
||||||
"/#test1:/bla-bla1/some/path/#test2:/#enc:KOI8-R/bla-bla2/some/path#test3:/111/22/33"
|
"/#test1/bla-bla1/some/path/#test2/#enc:KOI8-R/bla-bla2/some/path#test3/111/22/33"
|
||||||
);
|
);
|
||||||
|
|
||||||
encoding_check (
|
encoding_check (
|
||||||
"/#test1:/bla-bla1/#enc:IBM866/some/path/#test2:/bla-bla2/#enc:KOI8-R/some/path#test3:/111/22/33",
|
"/#test1/bla-bla1/#enc:IBM866/some/path/#test2/bla-bla2/#enc:KOI8-R/some/path#test3/111/22/33",
|
||||||
"/#test1:/#enc:IBM866/bla-bla1/some/path/#test2:/#enc:KOI8-R/bla-bla2/some/path#test3:/111/22/33"
|
"/#test1/#enc:IBM866/bla-bla1/some/path/#test2/#enc:KOI8-R/bla-bla2/some/path#test3/111/22/33"
|
||||||
);
|
);
|
||||||
|
|
||||||
encoding_check (
|
encoding_check (
|
||||||
"/#test1:/bla-bla1/some/path/#test2:/bla-bla2/#enc:IBM866/#enc:KOI8-R/some/path#test3:/111/22/33",
|
"/#test1/bla-bla1/some/path/#test2/bla-bla2/#enc:IBM866/#enc:KOI8-R/some/path#test3/111/22/33",
|
||||||
"/#test1:/bla-bla1/some/path/#test2:/#enc:KOI8-R/bla-bla2/some/path#test3:/111/22/33"
|
"/#test1/bla-bla1/some/path/#test2/#enc:KOI8-R/bla-bla2/some/path#test3/111/22/33"
|
||||||
);
|
);
|
||||||
|
|
||||||
encoding_check (
|
encoding_check (
|
||||||
"/#test1:/bla-bla1/some/path/#test2:/bla-bla2/#enc:IBM866/some/#enc:KOI8-R/path#test3:/111/22/33",
|
"/#test1/bla-bla1/some/path/#test2/bla-bla2/#enc:IBM866/some/#enc:KOI8-R/path#test3/111/22/33",
|
||||||
"/#test1:/bla-bla1/some/path/#test2:/#enc:KOI8-R/bla-bla2/some/path#test3:/111/22/33"
|
"/#test1/bla-bla1/some/path/#test2/#enc:KOI8-R/bla-bla2/some/path#test3/111/22/33"
|
||||||
);
|
);
|
||||||
|
|
||||||
encoding_check (
|
encoding_check (
|
||||||
"/#test1:/bla-bla1/some/path/#test2:/#enc:IBM866/bla-bla2/#enc:KOI8-R/some/path#test3:/111/22/33",
|
"/#test1/bla-bla1/some/path/#test2/#enc:IBM866/bla-bla2/#enc:KOI8-R/some/path#test3/111/22/33",
|
||||||
"/#test1:/bla-bla1/some/path/#test2:/#enc:KOI8-R/bla-bla2/some/path#test3:/111/22/33"
|
"/#test1/bla-bla1/some/path/#test2/#enc:KOI8-R/bla-bla2/some/path#test3/111/22/33"
|
||||||
);
|
);
|
||||||
|
|
||||||
encoding_check (
|
encoding_check (
|
||||||
"/#test1:/bla-bla1/some/path/#enc:IBM866/#test2:/bla-bla2/#enc:KOI8-R/some/path#test3:/111/22/33",
|
"/#test1/bla-bla1/some/path/#enc:IBM866/#test2/bla-bla2/#enc:KOI8-R/some/path#test3/111/22/33",
|
||||||
"/#test1:/#enc:IBM866/bla-bla1/some/path/#test2:/#enc:KOI8-R/bla-bla2/some/path#test3:/111/22/33"
|
"/#test1/#enc:IBM866/bla-bla1/some/path/#test2/#enc:KOI8-R/bla-bla2/some/path#test3/111/22/33"
|
||||||
);
|
);
|
||||||
|
|
||||||
free_codepages_list ();
|
free_codepages_list ();
|
||||||
@ -251,7 +251,7 @@ START_TEST (test_vfs_path_from_to_string_encoding)
|
|||||||
|
|
||||||
END_TEST
|
END_TEST
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
#define ETALON_STR "/path/to/file.ext#test1:/#enc:KOI8-R"
|
#define ETALON_STR "/path/to/file.ext#test1/#enc:KOI8-R"
|
||||||
START_TEST (test_vfs_path_encoding_at_end)
|
START_TEST (test_vfs_path_encoding_at_end)
|
||||||
{
|
{
|
||||||
vfs_path_t *vpath;
|
vfs_path_t *vpath;
|
||||||
|
@ -160,6 +160,50 @@ vfs_canon (const char *path)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
/**
|
||||||
|
* Build URL parameters (such as user:pass@host:port) from one path element object
|
||||||
|
*
|
||||||
|
* @param element path element
|
||||||
|
*
|
||||||
|
* @return newly allocated string
|
||||||
|
*/
|
||||||
|
|
||||||
|
static char *
|
||||||
|
vfs_path_build_url_params_str (vfs_path_element_t * element)
|
||||||
|
{
|
||||||
|
GString *buffer;
|
||||||
|
|
||||||
|
if (element == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
buffer = g_string_new ("");
|
||||||
|
|
||||||
|
if (element->user != NULL)
|
||||||
|
g_string_append (buffer, element->user);
|
||||||
|
|
||||||
|
if (element->password != NULL)
|
||||||
|
{
|
||||||
|
g_string_append_c (buffer, ':');
|
||||||
|
g_string_append (buffer, element->password);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (element->host != NULL)
|
||||||
|
{
|
||||||
|
if ((element->user != NULL) || (element->password != NULL))
|
||||||
|
g_string_append_c (buffer, '@');
|
||||||
|
g_string_append (buffer, element->host);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((element->port) != 0 && (element->host != NULL))
|
||||||
|
{
|
||||||
|
g_string_append_c (buffer, ':');
|
||||||
|
g_string_append_printf (buffer, "%d", element->port);
|
||||||
|
}
|
||||||
|
|
||||||
|
return g_string_free (buffer, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
/** get encoding after last #enc: or NULL, if part does not contain #enc:
|
/** get encoding after last #enc: or NULL, if part does not contain #enc:
|
||||||
*
|
*
|
||||||
@ -358,11 +402,21 @@ vfs_path_to_str_elements_count (const vfs_path_t * vpath, int elements_count)
|
|||||||
{
|
{
|
||||||
vfs_path_element_t *element = vfs_path_get_by_index (vpath, element_index);
|
vfs_path_element_t *element = vfs_path_get_by_index (vpath, element_index);
|
||||||
|
|
||||||
if (element->raw_url_str != NULL)
|
if (element->vfs_prefix != NULL)
|
||||||
{
|
{
|
||||||
g_string_append (buffer, "#");
|
char *url_str;
|
||||||
g_string_append (buffer, element->raw_url_str);
|
g_string_append_c (buffer, '#');
|
||||||
|
g_string_append (buffer, element->vfs_prefix);
|
||||||
|
|
||||||
|
url_str = vfs_path_build_url_params_str (element);
|
||||||
|
if (*url_str != '\0')
|
||||||
|
{
|
||||||
|
g_string_append_c (buffer, ':');
|
||||||
|
g_string_append (buffer, url_str);
|
||||||
|
}
|
||||||
|
g_free (url_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (element->encoding != NULL)
|
if (element->encoding != NULL)
|
||||||
{
|
{
|
||||||
g_string_append (buffer, PATH_SEP_STR VFS_ENCODING_PREFIX);
|
g_string_append (buffer, PATH_SEP_STR VFS_ENCODING_PREFIX);
|
||||||
@ -422,7 +476,7 @@ vfs_path_from_str (const char *path_str)
|
|||||||
{
|
{
|
||||||
char *url_params;
|
char *url_params;
|
||||||
element = g_new0 (vfs_path_element_t, 1);
|
element = g_new0 (vfs_path_element_t, 1);
|
||||||
element->class = vfs_prefix_to_class (op);
|
element->class = class;
|
||||||
if (local == NULL)
|
if (local == NULL)
|
||||||
local = "";
|
local = "";
|
||||||
element->path = vfs_translate_path_n (local);
|
element->path = vfs_translate_path_n (local);
|
||||||
@ -430,8 +484,6 @@ vfs_path_from_str (const char *path_str)
|
|||||||
element->encoding = vfs_get_encoding (local);
|
element->encoding = vfs_get_encoding (local);
|
||||||
element->dir.converter = INVALID_CONV;
|
element->dir.converter = INVALID_CONV;
|
||||||
|
|
||||||
element->raw_url_str = g_strdup (op);
|
|
||||||
|
|
||||||
url_params = strchr (op, ':'); /* skip VFS prefix */
|
url_params = strchr (op, ':'); /* skip VFS prefix */
|
||||||
if (url_params != NULL)
|
if (url_params != NULL)
|
||||||
{
|
{
|
||||||
@ -450,7 +502,6 @@ vfs_path_from_str (const char *path_str)
|
|||||||
element = g_new0 (vfs_path_element_t, 1);
|
element = g_new0 (vfs_path_element_t, 1);
|
||||||
element->class = g_ptr_array_index (vfs__classes_list, 0);
|
element->class = g_ptr_array_index (vfs__classes_list, 0);
|
||||||
element->path = vfs_translate_path_n (path);
|
element->path = vfs_translate_path_n (path);
|
||||||
element->raw_url_str = NULL;
|
|
||||||
|
|
||||||
element->encoding = vfs_get_encoding (path);
|
element->encoding = vfs_get_encoding (path);
|
||||||
element->dir.converter = INVALID_CONV;
|
element->dir.converter = INVALID_CONV;
|
||||||
@ -720,7 +771,6 @@ vfs_path_serialize (const vfs_path_t * vpath, GError ** error)
|
|||||||
mc_config_set_string_raw (cpath, groupname, "class-name", element->class->name);
|
mc_config_set_string_raw (cpath, groupname, "class-name", element->class->name);
|
||||||
mc_config_set_string_raw (cpath, groupname, "encoding", element->encoding);
|
mc_config_set_string_raw (cpath, groupname, "encoding", element->encoding);
|
||||||
|
|
||||||
mc_config_set_string_raw (cpath, groupname, "raw_url_str", element->raw_url_str);
|
|
||||||
mc_config_set_string_raw (cpath, groupname, "vfs_prefix", element->vfs_prefix);
|
mc_config_set_string_raw (cpath, groupname, "vfs_prefix", element->vfs_prefix);
|
||||||
|
|
||||||
mc_config_set_string_raw (cpath, groupname, "user", element->user);
|
mc_config_set_string_raw (cpath, groupname, "user", element->user);
|
||||||
@ -791,7 +841,6 @@ vfs_path_deserialize (const char *data, GError ** error)
|
|||||||
element->path = mc_config_get_string_raw (cpath, groupname, "path", NULL);
|
element->path = mc_config_get_string_raw (cpath, groupname, "path", NULL);
|
||||||
element->encoding = mc_config_get_string_raw (cpath, groupname, "encoding", NULL);
|
element->encoding = mc_config_get_string_raw (cpath, groupname, "encoding", NULL);
|
||||||
|
|
||||||
element->raw_url_str = mc_config_get_string_raw (cpath, groupname, "raw_url_str", NULL);
|
|
||||||
element->vfs_prefix = mc_config_get_string_raw (cpath, groupname, "vfs_prefix", NULL);
|
element->vfs_prefix = mc_config_get_string_raw (cpath, groupname, "vfs_prefix", NULL);
|
||||||
|
|
||||||
element->user = mc_config_get_string_raw (cpath, groupname, "user", NULL);
|
element->user = mc_config_get_string_raw (cpath, groupname, "user", NULL);
|
||||||
|
@ -32,8 +32,6 @@ typedef struct
|
|||||||
DIR *info;
|
DIR *info;
|
||||||
} dir;
|
} dir;
|
||||||
|
|
||||||
char *raw_url_str;
|
|
||||||
|
|
||||||
struct vfs_s_super *current_super_block;
|
struct vfs_s_super *current_super_block;
|
||||||
} vfs_path_element_t;
|
} vfs_path_element_t;
|
||||||
|
|
||||||
|
@ -89,28 +89,6 @@ static vfs_path_t *current_path = NULL;
|
|||||||
static GPtrArray *vfs_openfiles;
|
static GPtrArray *vfs_openfiles;
|
||||||
static long vfs_free_handle_list = -1;
|
static long vfs_free_handle_list = -1;
|
||||||
|
|
||||||
static const struct
|
|
||||||
{
|
|
||||||
const char *name;
|
|
||||||
size_t name_len;
|
|
||||||
const char *substitute;
|
|
||||||
} url_table[] =
|
|
||||||
{
|
|
||||||
/* *INDENT-OFF* */
|
|
||||||
#ifdef ENABLE_VFS_FTP
|
|
||||||
{ "ftp://", 6, "/#ftp:" },
|
|
||||||
#endif
|
|
||||||
#ifdef ENABLE_VFS_FISH
|
|
||||||
{ "sh://", 5, "/#sh:" },
|
|
||||||
{ "ssh://", 6, "/#sh:" },
|
|
||||||
#endif
|
|
||||||
#ifdef ENABLE_VFS_SMB
|
|
||||||
{ "smb://", 6, "/#smb:" },
|
|
||||||
#endif
|
|
||||||
{ "a:", 2, "/#a" }
|
|
||||||
/* *INDENT-ON* */
|
|
||||||
};
|
|
||||||
|
|
||||||
/*** file scope functions ************************************************************************/
|
/*** file scope functions ************************************************************************/
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
/* now used only by vfs_translate_path, but could be used in other vfs
|
/* now used only by vfs_translate_path, but could be used in other vfs
|
||||||
@ -521,26 +499,6 @@ vfs_fill_names (fill_names_f func)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
/**
|
|
||||||
* Returns vfs path corresponding to given url. If passed string is
|
|
||||||
* not recognized as url, g_strdup(url) is returned.
|
|
||||||
*/
|
|
||||||
|
|
||||||
char *
|
|
||||||
vfs_translate_url (const char *url)
|
|
||||||
{
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
for (i = 0; i < sizeof (url_table) / sizeof (url_table[0]); i++)
|
|
||||||
if (strncmp (url, url_table[i].name, url_table[i].name_len) == 0)
|
|
||||||
return g_strconcat (url_table[i].substitute, url + url_table[i].name_len,
|
|
||||||
(char *) NULL);
|
|
||||||
|
|
||||||
return g_strdup (url);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
vfs_file_is_local (const vfs_path_t * vpath)
|
vfs_file_is_local (const vfs_path_t * vpath)
|
||||||
{
|
{
|
||||||
|
@ -237,7 +237,6 @@ gboolean vfs_current_is_local (void);
|
|||||||
gboolean vfs_file_is_local (const vfs_path_t * vpath);
|
gboolean vfs_file_is_local (const vfs_path_t * vpath);
|
||||||
|
|
||||||
char *vfs_strip_suffix_from_filename (const char *filename);
|
char *vfs_strip_suffix_from_filename (const char *filename);
|
||||||
char *vfs_translate_url (const char *url);
|
|
||||||
|
|
||||||
struct vfs_class *vfs_split (char *path, char **inpath, char **op);
|
struct vfs_class *vfs_split (char *path, char **inpath, char **op);
|
||||||
char *vfs_path (const char *path);
|
char *vfs_path (const char *path);
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
#include "lib/tty/key.h"
|
#include "lib/tty/key.h"
|
||||||
#include "lib/tty/mouse.h"
|
#include "lib/tty/mouse.h"
|
||||||
#include "lib/mcconfig.h"
|
#include "lib/mcconfig.h"
|
||||||
#include "lib/vfs/vfs.h" /* For vfs_translate_url() */
|
#include "lib/vfs/vfs.h" /* For mc_get_current_wd() */
|
||||||
#include "lib/strutil.h"
|
#include "lib/strutil.h"
|
||||||
#include "lib/widget.h"
|
#include "lib/widget.h"
|
||||||
#include "lib/event.h"
|
#include "lib/event.h"
|
||||||
@ -1185,7 +1185,7 @@ save_panel_dir (int idx)
|
|||||||
|
|
||||||
g_free (panels[idx].last_saved_dir); /* last path no needed */
|
g_free (panels[idx].last_saved_dir); /* last path no needed */
|
||||||
/* Because path can be nonlocal */
|
/* Because path can be nonlocal */
|
||||||
panels[idx].last_saved_dir = vfs_translate_url (widget_work_dir);
|
panels[idx].last_saved_dir = g_strdup (widget_work_dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@
|
|||||||
#include "lib/skin.h"
|
#include "lib/skin.h"
|
||||||
#include "lib/util.h"
|
#include "lib/util.h"
|
||||||
|
|
||||||
#include "lib/vfs/vfs.h" /* vfs_translate_url() */
|
#include "lib/vfs/vfs.h"
|
||||||
|
|
||||||
#include "src/args.h"
|
#include "src/args.h"
|
||||||
#include "src/subshell.h"
|
#include "src/subshell.h"
|
||||||
@ -465,23 +465,6 @@ toggle_panels_split (void)
|
|||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/**
|
|
||||||
* Just a hack for allowing url-like pathnames to be accepted from the
|
|
||||||
* command line.
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
translated_mc_chdir (char *dir)
|
|
||||||
{
|
|
||||||
char *newdir;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
newdir = vfs_translate_url (dir);
|
|
||||||
ret = mc_chdir (newdir);
|
|
||||||
g_free (newdir);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
#if ENABLE_VFS
|
#if ENABLE_VFS
|
||||||
|
|
||||||
/* event helper */
|
/* event helper */
|
||||||
@ -624,7 +607,7 @@ create_panels (void)
|
|||||||
*/
|
*/
|
||||||
mc_get_current_wd (original_dir, sizeof (original_dir) - 2);
|
mc_get_current_wd (original_dir, sizeof (original_dir) - 2);
|
||||||
}
|
}
|
||||||
translated_mc_chdir (mc_run_param0);
|
mc_chdir (mc_run_param0);
|
||||||
}
|
}
|
||||||
set_display_type (current_index, current_mode);
|
set_display_type (current_index, current_mode);
|
||||||
|
|
||||||
@ -632,8 +615,8 @@ create_panels (void)
|
|||||||
if (mc_run_param1 != NULL)
|
if (mc_run_param1 != NULL)
|
||||||
{
|
{
|
||||||
if (original_dir[0] != '\0')
|
if (original_dir[0] != '\0')
|
||||||
translated_mc_chdir (original_dir);
|
mc_chdir (original_dir);
|
||||||
translated_mc_chdir (mc_run_param1);
|
mc_chdir (mc_run_param1);
|
||||||
}
|
}
|
||||||
set_display_type (other_index, other_mode);
|
set_display_type (other_index, other_mode);
|
||||||
|
|
||||||
|
@ -2626,7 +2626,6 @@ _do_panel_cd (WPanel * panel, const char *new_dir, enum cd_enum cd_type)
|
|||||||
const char *directory;
|
const char *directory;
|
||||||
char *olddir;
|
char *olddir;
|
||||||
char temp[MC_MAXPATHLEN];
|
char temp[MC_MAXPATHLEN];
|
||||||
char *translated_url;
|
|
||||||
|
|
||||||
if (cd_type == cd_parse_command)
|
if (cd_type == cd_parse_command)
|
||||||
{
|
{
|
||||||
@ -2635,7 +2634,6 @@ _do_panel_cd (WPanel * panel, const char *new_dir, enum cd_enum cd_type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
olddir = g_strdup (panel->cwd);
|
olddir = g_strdup (panel->cwd);
|
||||||
new_dir = translated_url = vfs_translate_url (new_dir);
|
|
||||||
|
|
||||||
/* Convert *new_path to a suitable pathname, handle ~user */
|
/* Convert *new_path to a suitable pathname, handle ~user */
|
||||||
|
|
||||||
@ -2653,10 +2651,8 @@ _do_panel_cd (WPanel * panel, const char *new_dir, enum cd_enum cd_type)
|
|||||||
{
|
{
|
||||||
strcpy (panel->cwd, olddir);
|
strcpy (panel->cwd, olddir);
|
||||||
g_free (olddir);
|
g_free (olddir);
|
||||||
g_free (translated_url);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
g_free (translated_url);
|
|
||||||
|
|
||||||
/* Success: save previous directory, shutdown status of previous dir */
|
/* Success: save previous directory, shutdown status of previous dir */
|
||||||
strcpy (panel->lwd, olddir);
|
strcpy (panel->lwd, olddir);
|
||||||
|
@ -1581,7 +1581,7 @@ init_fish (void)
|
|||||||
|
|
||||||
vfs_s_init_class (&vfs_fish_ops, &fish_subclass);
|
vfs_s_init_class (&vfs_fish_ops, &fish_subclass);
|
||||||
vfs_fish_ops.name = "fish";
|
vfs_fish_ops.name = "fish";
|
||||||
vfs_fish_ops.prefix = "sh:";
|
vfs_fish_ops.prefix = "sh";
|
||||||
vfs_fish_ops.fill_names = fish_fill_names;
|
vfs_fish_ops.fill_names = fish_fill_names;
|
||||||
vfs_fish_ops.chmod = fish_chmod;
|
vfs_fish_ops.chmod = fish_chmod;
|
||||||
vfs_fish_ops.chown = fish_chown;
|
vfs_fish_ops.chown = fish_chown;
|
||||||
|
@ -2553,7 +2553,7 @@ init_ftpfs (void)
|
|||||||
vfs_s_init_class (&vfs_ftpfs_ops, &ftpfs_subclass);
|
vfs_s_init_class (&vfs_ftpfs_ops, &ftpfs_subclass);
|
||||||
vfs_ftpfs_ops.name = "ftpfs";
|
vfs_ftpfs_ops.name = "ftpfs";
|
||||||
vfs_ftpfs_ops.flags = VFSF_NOLINKS;
|
vfs_ftpfs_ops.flags = VFSF_NOLINKS;
|
||||||
vfs_ftpfs_ops.prefix = "ftp:";
|
vfs_ftpfs_ops.prefix = "ftp";
|
||||||
vfs_ftpfs_ops.done = &ftpfs_done;
|
vfs_ftpfs_ops.done = &ftpfs_done;
|
||||||
vfs_ftpfs_ops.fill_names = ftpfs_fill_names;
|
vfs_ftpfs_ops.fill_names = ftpfs_fill_names;
|
||||||
vfs_ftpfs_ops.chmod = ftpfs_chmod;
|
vfs_ftpfs_ops.chmod = ftpfs_chmod;
|
||||||
|
@ -2200,7 +2200,7 @@ init_smbfs (void)
|
|||||||
tcp_init ();
|
tcp_init ();
|
||||||
|
|
||||||
vfs_smbfs_ops.name = "smbfs";
|
vfs_smbfs_ops.name = "smbfs";
|
||||||
vfs_smbfs_ops.prefix = "smb:";
|
vfs_smbfs_ops.prefix = "smb";
|
||||||
vfs_smbfs_ops.flags = VFSF_NOLINKS;
|
vfs_smbfs_ops.flags = VFSF_NOLINKS;
|
||||||
vfs_smbfs_ops.init = smbfs_init;
|
vfs_smbfs_ops.init = smbfs_init;
|
||||||
vfs_smbfs_ops.fill_names = smbfs_fill_names;
|
vfs_smbfs_ops.fill_names = smbfs_fill_names;
|
||||||
|
@ -161,7 +161,7 @@ undelfs_get_path (const vfs_path_t * vpath, char **fsname, char **file)
|
|||||||
|
|
||||||
*fsname = NULL;
|
*fsname = NULL;
|
||||||
|
|
||||||
if (strncmp (dirname, "/#undel:", 8))
|
if (strncmp (dirname, "/#undel", 7))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dirname += 8;
|
dirname += 8;
|
||||||
@ -806,7 +806,7 @@ void
|
|||||||
init_undelfs (void)
|
init_undelfs (void)
|
||||||
{
|
{
|
||||||
vfs_undelfs_ops.name = "undelfs";
|
vfs_undelfs_ops.name = "undelfs";
|
||||||
vfs_undelfs_ops.prefix = "undel:";
|
vfs_undelfs_ops.prefix = "undel";
|
||||||
vfs_undelfs_ops.init = undelfs_init;
|
vfs_undelfs_ops.init = undelfs_init;
|
||||||
vfs_undelfs_ops.open = undelfs_open;
|
vfs_undelfs_ops.open = undelfs_open;
|
||||||
vfs_undelfs_ops.close = undelfs_close;
|
vfs_undelfs_ops.close = undelfs_close;
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user