From 34d74f09b1f25c3920e23b44cf7cc8d737691ae9 Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Tue, 2 Mar 2010 14:43:38 +0000 Subject: [PATCH] Ticket #1909: don't interpret trailing '+' as a plugin name. If EXTFS plugin doesn't require a file, that file name must be finished with '+': for example, rpms+. But trailing '+' actually is not a part of plugin name, it is an plugin attrubute. But in the current time trailing '+' must be used in VFS command: cd #rpms+ instead of cd #rpms This commit simplifies the usage of some EXTFS plugins. Also fixed VFS README. Signed-off-by: Andrew Borodin --- lib/vfs/mc-vfs/extfs.c | 28 ++++++++++++++++++---------- lib/vfs/mc-vfs/extfs/README | 33 +++++++++++++++++++-------------- 2 files changed, 37 insertions(+), 24 deletions(-) diff --git a/lib/vfs/mc-vfs/extfs.c b/lib/vfs/mc-vfs/extfs.c index 752ec99a..fbc8d7ba 100644 --- a/lib/vfs/mc-vfs/extfs.c +++ b/lib/vfs/mc-vfs/extfs.c @@ -583,16 +583,22 @@ extfs_read_archive (int fstype, const char *name, struct archive **pparc) static int extfs_which (struct vfs_class *me, const char *path) { + size_t path_len; size_t i; (void) me; + path_len = strlen (path); + for (i = 0; i < extfs_plugins->len; i++) { extfs_plugin_info_t *info; info = &g_array_index (extfs_plugins, extfs_plugin_info_t, i); - if (strcmp (path, info->prefix) == 0) + + if ((strncmp (path, info->prefix, path_len) == 0) + && ((info->prefix[path_len] == '\0') + || (info->prefix[path_len] == '+'))) return i; } return -1; @@ -1470,16 +1476,13 @@ extfs_get_plugins (const char *where, gboolean silent) * file system does not require an archive to work */ len = strlen (filename); - if (filename[len - 1] != '+') - info.need_archive = TRUE; - else - { - info.need_archive = FALSE; - len--; - } - + info.need_archive = (filename[len - 1] != '+'); info.path = g_strconcat (dirname, PATH_SEP_STR, (char *) NULL); - info.prefix = g_strndup (filename, len); + info.prefix = g_strdup (filename); + + /* prepare to compare file names without trailing '+' */ + if (!info.need_archive) + info.prefix[len - 1] = '\0'; /* don't overload already found plugin */ for (i = 0; i < extfs_plugins->len; i++) @@ -1503,7 +1506,12 @@ extfs_get_plugins (const char *where, gboolean silent) g_free (info.prefix); } else + { + /* restore file name */ + if (!info.need_archive) + info.prefix[len - 1] = '+'; g_array_append_val (extfs_plugins, info); + } } } } diff --git a/lib/vfs/mc-vfs/extfs/README b/lib/vfs/mc-vfs/extfs/README index 3b32afdc..0c21dda2 100644 --- a/lib/vfs/mc-vfs/extfs/README +++ b/lib/vfs/mc-vfs/extfs/README @@ -6,31 +6,36 @@ Starting with version 3.1, the Midnight Commander comes with so called extfs, which is one of the virtual filesystems. This system makes it possible to create new virtual filesystems for the GNU MC very easily. -Such work has two basic steps: +To handle requests, create a shell/perl/python/etc script/program +(with executable permissions) in $(libexecdir)/mc/extfs.d +or in ~/.mc/extfs.d. -Editing $(libdir)/extfs/extfs.ini. -Creating a shell script/program to handle requests. -(Note: $(libdir) should be substituted for actual libdir path stored when -configured or compiled, like /usr/local/lib/mc or /usr/lib/mc). +(Note: $(libexecdir) should be substituted for actual libexecdir path +stored when configured or compiled, like /usr/local/libexec or /usr/libexec). -The first one is very easy: -You assign a vfs suffix. For example, if you have .zip file, and would -like to see what's inside it, path will be +Assign a vfs suffix. For example, if you have .zip file, and would like +to see what's inside it, path will be /anypath/my.zip#uzip/some_path/... -Then you add a line extfs.ini file containing just that extension. If -your vfs does not require file to work on, add ':' to the end of name. - In this example, .zip is suffix, but I call vfs 'uzip'. Why? Well, what this vfs essentially does is UNzip. UN is too long, so I choosed U. Note that sometime in future filesystem like zip may exist: It will take whole tree and create .zip file from it. So /usr#zip will be zipfile containing whole /usr tree. -The second one may require some your knowledge of shell/c programming: -You have to create a program (with executable permissions) prefix in -$(libdir)/extfs (in our example $(libdir)/extfs/uzip). +If your vfs does not require file to work on, add '+' to the end of name. +Note, that trailing '+' in file name is not a part of vfs name, it is +just an vfs attribue. So you have not use it in vfs commands: + +cd #rpms + +is correct command, and + +cd #rpms+ + +is incorrect command. + * Commands that should be implemented by your shell script ---------------------------------------------------------- -- 2.11.4.GIT