Rename mc_config_get_profile_root() to mc_get_profile_root()

...and move it out from lib/mcconfig.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2016-11-29 11:33:10 +03:00
parent d1ad225177
commit 496abc0e1f
5 changed files with 31 additions and 30 deletions

View File

@ -107,8 +107,6 @@ const char *mc_config_get_cache_path (void);
const char *mc_config_get_path (void);
const char *mc_config_get_profile_root (void);
const char *mc_config_get_home_dir (void);
char *mc_config_get_full_path (const char *config_name);

View File

@ -279,30 +279,6 @@ mc_config_deprecated_dir_present (void)
/*** public functions ****************************************************************************/
/* --------------------------------------------------------------------------------------------- */
/**
* The "profile root" is the tree under which all of MC's user data &
* settings are stored.
*
* It defaults to the user's home dir. The user may override this default
* with the environment variable $MC_PROFILE_ROOT.
*/
const char *
mc_config_get_profile_root (void)
{
static const char *profile_root = NULL;
if (profile_root == NULL)
{
profile_root = g_getenv ("MC_PROFILE_ROOT");
if (profile_root == NULL || *profile_root == '\0')
profile_root = mc_config_get_home_dir ();
}
return profile_root;
}
/* --------------------------------------------------------------------------------------------- */
void
mc_config_init_config_paths (GError ** mcerror)
{
@ -317,7 +293,7 @@ mc_config_init_config_paths (GError ** mcerror)
return;
#if MC_HOMEDIR_XDG
if (strcmp (mc_config_get_profile_root (), mc_config_get_home_dir ()) != 0)
if (strcmp (mc_get_profile_root (), mc_config_get_home_dir ()) != 0)
{
/*
* The user overrode the default profile root.
@ -328,7 +304,7 @@ mc_config_init_config_paths (GError ** mcerror)
const char *profile_root;
profile_root = mc_config_get_profile_root ();
profile_root = mc_get_profile_root ();
dir = g_build_filename (profile_root, ".config", (char *) NULL);
mc_config_str = mc_config_init_one_config_path (dir, MC_USERCONF_DIR, mcerror);
@ -360,7 +336,7 @@ mc_config_init_config_paths (GError ** mcerror)
else
{
g_free (defined_userconf_dir);
dir = g_build_filename (mc_config_get_profile_root (), MC_USERCONF_DIR, (char *) NULL);
dir = g_build_filename (mc_get_profile_root (), MC_USERCONF_DIR, (char *) NULL);
}
mc_data_str = mc_cache_str = mc_config_str = mc_config_init_one_config_path (dir, "", mcerror);

View File

@ -1418,6 +1418,30 @@ guess_message_value (void)
return g_strdup (locale);
}
/* --------------------------------------------------------------------------------------------- */
/**
* The "profile root" is the tree under which all of MC's user data &
* settings are stored.
*
* It defaults to the user's home dir. The user may override this default
* with the environment variable $MC_PROFILE_ROOT.
*/
const char *
mc_get_profile_root (void)
{
static const char *profile_root = NULL;
if (profile_root == NULL)
{
profile_root = g_getenv ("MC_PROFILE_ROOT");
if (profile_root == NULL || *profile_root == '\0')
profile_root = mc_config_get_home_dir ();
}
return profile_root;
}
/* --------------------------------------------------------------------------------------------- */
/**
* Propagate error in simple way.

View File

@ -249,6 +249,8 @@ char *guess_message_value (void);
char *mc_build_filename (const char *first_element, ...);
char *mc_build_filenamev (const char *first_element, va_list args);
const char *mc_get_profile_root (void);
/* *INDENT-OFF* */
void mc_propagate_error (GError ** dest, int code, const char *format, ...) G_GNUC_PRINTF (3, 4);
void mc_replace_error (GError ** dest, int code, const char *format, ...) G_GNUC_PRINTF (3, 4);

View File

@ -33,6 +33,7 @@
#include "lib/global.h"
#include "lib/fileloc.h"
#include "lib/mcconfig.h"
#include "lib/util.h" /* mc_get_profile_root() */
#include "src/textconf.h"
@ -181,7 +182,7 @@ void
show_datadirs_extended (void)
{
(void) printf ("%s %s\n", _("Home directory:"), mc_config_get_home_dir ());
(void) printf ("%s %s\n", _("Profile root directory:"), mc_config_get_profile_root ());
(void) printf ("%s %s\n", _("Profile root directory:"), mc_get_profile_root ());
(void) puts ("");
PRINTF_GROUP (_("System data"));