extfs.ini file is replaced to extfs.d directory.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2010-01-27 16:22:56 +00:00
parent 2d43ad1bb4
commit ba1d909a7a
13 changed files with 102 additions and 81 deletions

View File

@ -589,20 +589,20 @@ lib/tty/Makefile
lib/vfs/Makefile
lib/vfs/mc-vfs/Makefile
lib/vfs/mc-vfs/extfs/Makefile
lib/vfs/mc-vfs/extfs/a
lib/vfs/mc-vfs/extfs/apt
lib/vfs/mc-vfs/extfs/a+
lib/vfs/mc-vfs/extfs/apt+
lib/vfs/mc-vfs/extfs/audio
lib/vfs/mc-vfs/extfs/deb
lib/vfs/mc-vfs/extfs/deba
lib/vfs/mc-vfs/extfs/debd
lib/vfs/mc-vfs/extfs/dpkg
lib/vfs/mc-vfs/extfs/dpkg+
lib/vfs/mc-vfs/extfs/iso9660
lib/vfs/mc-vfs/extfs/hp48
lib/vfs/mc-vfs/extfs/hp48+
lib/vfs/mc-vfs/extfs/lslR
lib/vfs/mc-vfs/extfs/mailfs
lib/vfs/mc-vfs/extfs/patchfs
lib/vfs/mc-vfs/extfs/rpms
lib/vfs/mc-vfs/extfs/s3
lib/vfs/mc-vfs/extfs/rpms+
lib/vfs/mc-vfs/extfs/s3+
lib/vfs/mc-vfs/extfs/uace
lib/vfs/mc-vfs/extfs/ualz
lib/vfs/mc-vfs/extfs/uar

View File

@ -29,6 +29,7 @@
#define CHARSETS_INDEX "mc.charsets"
#define MC_LIB_EXT "mc.ext"
#define MC_EXTFS_DIR "extfs.d"
#define MC_BASHRC_FILE "bashrc"
#define MC_CONFIG_FILE "ini"

View File

@ -8,6 +8,8 @@ DIST_SUBDIRS = extfs
SUBDIRS = extfs $(SAMBA_SUBDIRS)
AM_CFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir) $(SAMBA_CFLAGS)
AM_CPPFLAGS = -DLIBEXECDIR=\""$(libexecdir)/@PACKAGE@/"\"
BASICFILES = \
cpio.c \
direntry.c \

View File

@ -44,11 +44,13 @@
#include <fcntl.h>
#include <errno.h>
#include <sys/wait.h>
#include <unistd.h>
#include "lib/global.h"
#include "lib/fileloc.h"
#include "src/wtools.h" /* message() */
#include "src/main.h" /* print_vfs_message */
#include "src/wtools.h" /* message() */
#include "src/main.h" /* print_vfs_message */
#include "src/execute.h" /* For shell_execute */
#include "utilvfs.h"
@ -353,7 +355,7 @@ extfs_open_archive (int fstype, const char *name, struct archive **pparc)
tmp = name_quote (name, 0);
}
mc_extfsdir = concat_dir_and_file (mc_home_alt, "extfs" PATH_SEP_STR);
mc_extfsdir = g_build_path (PATH_SEP_STR, LIBEXECDIR, MC_EXTFS_DIR PATH_SEP_STR, (char *) NULL);
cmd = g_strconcat (mc_extfsdir, info->prefix, " list ",
local_name != NULL ? local_name : tmp, (char *) NULL);
g_free (tmp);
@ -722,7 +724,7 @@ extfs_cmd (const char *str_extfs_cmd, struct archive *archive,
archive_name = name_quote (extfs_get_archive_name (archive), 0);
quoted_localname = name_quote (localname, 0);
info = &g_array_index (extfs_plugins, extfs_plugin_info_t, archive->fstype);
mc_extfsdir = concat_dir_and_file (mc_home_alt, "extfs" PATH_SEP_STR);
mc_extfsdir = g_build_path (PATH_SEP_STR, LIBEXECDIR, MC_EXTFS_DIR PATH_SEP_STR, (char *) NULL);
cmd = g_strconcat (mc_extfsdir, info->prefix, str_extfs_cmd,
archive_name, " ", quoted_file, " ",
quoted_localname, (char *) NULL);
@ -753,7 +755,7 @@ extfs_run (struct vfs_class *me, const char *file)
g_free (p);
archive_name = name_quote (extfs_get_archive_name (archive), 0);
mc_extfsdir = concat_dir_and_file (mc_home_alt, "extfs" PATH_SEP_STR);
mc_extfsdir = g_build_path (PATH_SEP_STR, LIBEXECDIR, MC_EXTFS_DIR PATH_SEP_STR, (char *) NULL);
info = &g_array_index (extfs_plugins, extfs_plugin_info_t, archive->fstype);
cmd = g_strconcat (mc_extfsdir, info->prefix,
" run ", archive_name, " ", q, (char *) NULL);
@ -1361,61 +1363,78 @@ extfs_ungetlocalcopy (struct vfs_class *me, const char *path,
static int
extfs_init (struct vfs_class *me)
{
FILE *cfg;
char *mc_extfsini;
char key[256];
char *dirname;
GDir *dir;
const char *filename;
(void) me;
mc_extfsini = concat_dir_and_file (mc_home, "extfs" PATH_SEP_STR "extfs.ini");
cfg = fopen (mc_extfsini, "r");
dirname = g_build_path (PATH_SEP_STR, LIBEXECDIR, MC_EXTFS_DIR, (char *) NULL);
dir = g_dir_open (dirname, 0, NULL);
/* We may not use vfs_die() message or message or similar,
* UI is not initialized at this time and message would not
* appear on screen. */
if (cfg == NULL) {
fprintf (stderr, _("Warning: file %s not found\n"), mc_extfsini);
g_free (mc_extfsini);
if (dir == NULL) {
fprintf (stderr, _("Warning: cannot open %s directory\n"), dirname);
g_free (dirname);
return 0;
}
extfs_plugins = g_array_sized_new (FALSE, TRUE, sizeof (extfs_plugin_info_t), 32);
while (fgets (key, sizeof (key), cfg) != NULL) {
extfs_plugin_info_t info;
char *c;
while ((filename = g_dir_read_name (dir)) != NULL) {
char fullname[MC_MAXPATHLEN];
struct stat s;
/* Handle those with a trailing ':', those flag that the
* file system does not require an archive to work
*/
g_snprintf (fullname, sizeof (fullname), "%s" PATH_SEP_STR "%s", dirname, filename);
if (*key == '[') {
fprintf (stderr, "Warning: You need to update your %s file.\n",
mc_extfsini);
fclose (cfg);
g_free (mc_extfsini);
return 0;
if ((stat (fullname, &s) == 0)
&& S_ISREG (s.st_mode) && !S_ISDIR (s.st_mode)
&& (((s.st_mode & S_IXOTH) != 0) ||
((s.st_mode & S_IXUSR) != 0) ||
((s.st_mode & S_IXGRP) != 0))) {
int f;
f = open (fullname, O_RDONLY);
if (f > 0) {
size_t len;
extfs_plugin_info_t info;
close (f);
/* Handle those with a trailing '+', those flag that the
* 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.prefix = g_strndup (filename, len);
g_array_append_val (extfs_plugins, info);
}
}
if (*key == '#' || *key == '\n')
continue;
c = strchr (key, '\n');
if (c != '\0')
*c-- = '\0';
else /* Last line without newline or strlen (key) > 255 */
c = &key [strlen (key) - 1];
info.need_archive = !(*c == ':');
if (*c == ':')
*c = '\0';
if (*key != '\0')
info.prefix = g_strdup (key);
g_array_append_val (extfs_plugins, info);
}
fclose (cfg);
g_free (mc_extfsini);
g_dir_close (dir);
g_free (dirname);
#if 0
{
size_t i;
for (i = 0; i < extfs_plugins->len; i++) {
extfs_plugin_info_t *info;
info = &g_array_index (extfs_plugins, extfs_plugin_info_t, i);
mc_log ("%s %d\n", info->prefix, info->need_archive ? 1 : 0);
}
}
#endif
return 1;
}

View File

@ -1,29 +1,29 @@
extfsdir = $(pkgdatadir)/extfs
extfsdir = $(libexecdir)/@PACKAGE@/extfs.d
EXTFSCONFFILES = extfs.ini sfs.ini
EXTFSCONFFILES = sfs.ini
# Files to install and distribute other than extfs scripts
EXTFS_MISC = README
EXTFS_MISC = README README.extfs
# Scripts hat don't need adaptation to the local system
EXTFS_CONST = bpp rpm trpm u7z ucab
# Scripts that need adaptation to the local system - source files
EXTFS_IN = \
a.in \
apt.in \
a+.in \
apt+.in \
audio.in \
deb.in \
deba.in \
debd.in \
dpkg.in \
dpkg+.in \
iso9660.in \
hp48.in \
hp48+.in \
lslR.in \
mailfs.in \
patchfs.in \
rpms.in \
s3.in \
rpms+.in \
s3+.in \
uace.in \
ualz.in \
uar.in \
@ -38,20 +38,20 @@ EXTFS_IN = \
# Scripts that need adaptation to the local system - files to install
EXTFS_OUT = \
a \
apt \
a+ \
apt+ \
audio \
deb \
deba \
debd \
dpkg \
dpkg+ \
iso9660 \
hp48 \
hp48+ \
lslR \
mailfs \
patchfs \
rpms \
s3 \
rpms+ \
s3+ \
uace \
ualz \
uar \
@ -68,7 +68,7 @@ if ENABLE_VFS
extfs_DATA = $(EXTFS_MISC)
extfs_SCRIPTS = $(EXTFS_CONST) $(EXTFS_OUT)
extfsconfdir = $(sysconfdir)/@PACKAGE@/extfs
extfsconfdir = $(sysconfdir)/@PACKAGE@
extfsconf_DATA = $(EXTFSCONFFILES)
endif

View File

@ -1,7 +1,7 @@
# Each external VFS type must be registered here if you want to use it
# Trailing colon means that the filesystem is not tied to a certain file
# Each external VFS type must be registered in extfs.d directory if you want to use it.
# Trailing plus means that the filesystem is not tied to a certain file.
# Popular pc archivers
# Popular PC archivers
uzip
uzoo
ulha
@ -9,7 +9,7 @@ urar
uha
u7z
ualz
# For arj usage you need a special patch to unarj (see unarj.diff)
# FIXME: for arj usage you need a special patch to unarj (see unarj.diff)
uarj
uarc
uace
@ -24,14 +24,14 @@ uar
rpm
deb
# a: - mtools filesystem
a:
# a+ - mtools filesystem
a+
# For browsing lslR listings (found on many ftp sites)
lslR
# Hewlett Packard calculator
hp48:
hp48+
# Commodore 64/128 d64/D64 files
uc1541
@ -43,18 +43,18 @@ patchfs
mailfs
# List all installed RPM packages on the system
rpms:
rpms+
trpm
# dpkg frontend
dpkg:
dpkg+
debd
# apt frontend
apt:
apt+
deba
# Simple filesystem for audio cdroms. Use /dev/cdrom#audio (or /#audio).
# Simple filesystem for audio cdroms. Use /dev/cdrom#audio (or /#audio)
audio
# Package of Bad Penguin (an Italian GNU/Linux distribution)
@ -64,5 +64,4 @@ bpp
iso9660
# Amazon S3
s3:
s3+

View File

@ -344,10 +344,10 @@ static int sfs_init (struct vfs_class *me)
(void) me;
mc_sfsini = concat_dir_and_file (mc_home, "extfs" PATH_SEP_STR "sfs.ini");
mc_sfsini = g_build_filename (mc_home, "sfs.ini", (char *) NULL);
cfg = fopen (mc_sfsini, "r");
if (!cfg){
if (cfg == NULL) {
fprintf (stderr, _("Warning: file %s not found\n"), mc_sfsini);
g_free (mc_sfsini);
return 0;