mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-03 10:04:32 +03:00
Moved initialization of mc_global.share_data_dir and mc_global.sysconf_dir to library
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
parent
e784cf65a5
commit
7dad2df6a8
@ -9,5 +9,6 @@ libmcconfig_la_SOURCES = \
|
|||||||
|
|
||||||
libmcconfig_la_CFLAGS = -I$(top_srcdir) \
|
libmcconfig_la_CFLAGS = -I$(top_srcdir) \
|
||||||
$(GLIB_CFLAGS) \
|
$(GLIB_CFLAGS) \
|
||||||
-DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\"
|
-DDATADIR=\""$(pkgdatadir)/"\" \
|
||||||
|
-DLOCALEDIR=\""$(localedir)"\" \
|
||||||
|
-DSYSCONFDIR=\""$(sysconfdir)/@PACKAGE@/"\"
|
||||||
|
@ -206,6 +206,8 @@ mc_config_copy (const char *old_name, const char *new_name, GError ** error)
|
|||||||
void
|
void
|
||||||
mc_config_init_config_paths (GError ** error)
|
mc_config_init_config_paths (GError ** error)
|
||||||
{
|
{
|
||||||
|
const char *mc_datadir;
|
||||||
|
|
||||||
char *u_config_dir = (char *) g_get_user_config_dir ();
|
char *u_config_dir = (char *) g_get_user_config_dir ();
|
||||||
char *u_data_dir = (char *) g_get_user_data_dir ();
|
char *u_data_dir = (char *) g_get_user_data_dir ();
|
||||||
char *u_cache_dir = (char *) g_get_user_cache_dir ();
|
char *u_cache_dir = (char *) g_get_user_cache_dir ();
|
||||||
@ -230,6 +232,17 @@ mc_config_init_config_paths (GError ** error)
|
|||||||
g_free (u_data_dir);
|
g_free (u_data_dir);
|
||||||
g_free (u_cache_dir);
|
g_free (u_cache_dir);
|
||||||
g_free (u_config_dir);
|
g_free (u_config_dir);
|
||||||
|
|
||||||
|
/* This is the directory, where MC was installed, on Unix this is DATADIR */
|
||||||
|
/* and can be overriden by the MC_DATADIR environment variable */
|
||||||
|
mc_datadir = g_getenv ("MC_DATADIR");
|
||||||
|
if (mc_datadir != NULL)
|
||||||
|
mc_global.sysconfig_dir = g_strdup (mc_datadir);
|
||||||
|
else
|
||||||
|
mc_global.sysconfig_dir = g_strdup (SYSCONFDIR);
|
||||||
|
|
||||||
|
mc_global.share_data_dir = g_strdup (DATADIR);
|
||||||
|
|
||||||
xdg_vars_initialized = TRUE;
|
xdg_vars_initialized = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,6 +258,9 @@ mc_config_deinit_config_paths (void)
|
|||||||
g_free (xdg_cache);
|
g_free (xdg_cache);
|
||||||
g_free (xdg_data);
|
g_free (xdg_data);
|
||||||
|
|
||||||
|
g_free (mc_global.share_data_dir);
|
||||||
|
g_free (mc_global.sysconfig_dir);
|
||||||
|
|
||||||
xdg_vars_initialized = FALSE;
|
xdg_vars_initialized = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,10 +8,7 @@ if USE_DIFF
|
|||||||
SUBDIRS += diffviewer
|
SUBDIRS += diffviewer
|
||||||
endif
|
endif
|
||||||
|
|
||||||
AM_CPPFLAGS = -DDATADIR=\""$(pkgdatadir)/"\" \
|
AM_CPPFLAGS = -DLOCALEDIR=\""$(localedir)"\"
|
||||||
-DLOCALEDIR=\""$(localedir)"\" \
|
|
||||||
-DSYSCONFDIR=\""$(sysconfdir)/@PACKAGE@/"\"
|
|
||||||
|
|
||||||
|
|
||||||
if CONS_SAVER
|
if CONS_SAVER
|
||||||
SUBDIRS += consaver
|
SUBDIRS += consaver
|
||||||
|
36
src/main.c
36
src/main.c
@ -156,7 +156,6 @@ static void
|
|||||||
OS_Setup (void)
|
OS_Setup (void)
|
||||||
{
|
{
|
||||||
const char *shell_env = getenv ("SHELL");
|
const char *shell_env = getenv ("SHELL");
|
||||||
const char *mc_libdir;
|
|
||||||
|
|
||||||
if ((shell_env == NULL) || (shell_env[0] == '\0'))
|
if ((shell_env == NULL) || (shell_env[0] == '\0'))
|
||||||
{
|
{
|
||||||
@ -173,21 +172,6 @@ OS_Setup (void)
|
|||||||
g_free (shell);
|
g_free (shell);
|
||||||
shell = g_strdup ("/bin/sh");
|
shell = g_strdup ("/bin/sh");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This is the directory, where MC was installed, on Unix this is DATADIR */
|
|
||||||
/* and can be overriden by the MC_DATADIR environment variable */
|
|
||||||
mc_libdir = getenv ("MC_DATADIR");
|
|
||||||
if (mc_libdir != NULL)
|
|
||||||
{
|
|
||||||
mc_global.sysconfig_dir = g_strdup (mc_libdir);
|
|
||||||
mc_global.share_data_dir = g_strdup (SYSCONFDIR);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mc_global.sysconfig_dir = g_strdup (SYSCONFDIR);
|
|
||||||
mc_global.share_data_dir = g_strdup (DATADIR);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
@ -408,6 +392,13 @@ main (int argc, char *argv[])
|
|||||||
|
|
||||||
str_init_strings (NULL);
|
str_init_strings (NULL);
|
||||||
|
|
||||||
|
/* Initialize and create home directories */
|
||||||
|
/* do it after the screen library initialization to show the error message */
|
||||||
|
mc_config_init_config_paths (&error);
|
||||||
|
|
||||||
|
if (error == NULL && mc_config_deprecated_dir_present ())
|
||||||
|
mc_config_migrate_from_old_place (&error);
|
||||||
|
|
||||||
vfs_init ();
|
vfs_init ();
|
||||||
vfs_plugins_init ();
|
vfs_plugins_init ();
|
||||||
vfs_setup_work_dir ();
|
vfs_setup_work_dir ();
|
||||||
@ -437,17 +428,6 @@ main (int argc, char *argv[])
|
|||||||
/* We need this, since ncurses endwin () doesn't restore the signals */
|
/* We need this, since ncurses endwin () doesn't restore the signals */
|
||||||
save_stop_handler ();
|
save_stop_handler ();
|
||||||
|
|
||||||
/* Initialize and create home directories */
|
|
||||||
/* do it after the screen library initialization to show the error message */
|
|
||||||
mc_config_init_config_paths (&error);
|
|
||||||
if (error == NULL)
|
|
||||||
{
|
|
||||||
if (mc_config_deprecated_dir_present ())
|
|
||||||
{
|
|
||||||
mc_config_migrate_from_old_place (&error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Must be done before init_subshell, to set up the terminal size: */
|
/* Must be done before init_subshell, to set up the terminal size: */
|
||||||
/* FIXME: Should be removed and LINES and COLS computed on subshell */
|
/* FIXME: Should be removed and LINES and COLS computed on subshell */
|
||||||
tty_init (mc_global.args.slow_terminal, mc_global.args.ugly_line_drawing);
|
tty_init (mc_global.args.slow_terminal, mc_global.args.ugly_line_drawing);
|
||||||
@ -563,8 +543,6 @@ main (int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
g_free (last_wd_string);
|
g_free (last_wd_string);
|
||||||
|
|
||||||
g_free (mc_global.share_data_dir);
|
|
||||||
g_free (mc_global.sysconfig_dir);
|
|
||||||
g_free (shell);
|
g_free (shell);
|
||||||
|
|
||||||
done_key ();
|
done_key ();
|
||||||
|
@ -421,7 +421,7 @@ sfs_init (struct vfs_class *me)
|
|||||||
|
|
||||||
if (cfg == NULL)
|
if (cfg == NULL)
|
||||||
{
|
{
|
||||||
fprintf (stderr, _("Warning: file %s not found\n"), mc_sfsini);
|
fprintf (stderr, _("%s: Warning: file %s not found\n"), "sfs_init()", mc_sfsini);
|
||||||
g_free (mc_sfsini);
|
g_free (mc_sfsini);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user