Added function mc_config_get_full_path() for search user's config files by short names.

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
Slava Zanko 2011-11-24 01:28:07 +03:00
parent 25c9267ac3
commit 6c32fa3b84
19 changed files with 105 additions and 71 deletions

View File

@ -199,7 +199,7 @@ mc_fhl_init_from_standard_files (mc_fhl_t * fhl)
gboolean ok; gboolean ok;
/* ${XDG_CONFIG_HOME}/mc/filehighlight.ini */ /* ${XDG_CONFIG_HOME}/mc/filehighlight.ini */
name = g_build_filename (mc_config_get_data_path (), MC_FHL_INI_FILE, (char *) NULL); name = mc_config_get_full_path (MC_FHL_INI_FILE);
ok = mc_fhl_read_ini_file (fhl, name); ok = mc_fhl_read_ini_file (fhl, name);
g_free (name); g_free (name);
if (ok) if (ok)

View File

@ -104,7 +104,7 @@ get_log_filename (void)
if (mc_config_has_param (mc_main_config, CONFIG_GROUP_NAME, CONFIG_KEY_NAME_FILE)) if (mc_config_has_param (mc_main_config, CONFIG_GROUP_NAME, CONFIG_KEY_NAME_FILE))
return mc_config_get_string (mc_main_config, CONFIG_GROUP_NAME, CONFIG_KEY_NAME_FILE, NULL); return mc_config_get_string (mc_main_config, CONFIG_GROUP_NAME, CONFIG_KEY_NAME_FILE, NULL);
return g_build_filename (mc_config_get_cache_path (), "mc.log", NULL); return mc_config_get_full_path ("mc.log");
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */

View File

@ -108,6 +108,8 @@ const char *mc_config_get_path (void);
const char *mc_config_get_home_dir (void); const char *mc_config_get_home_dir (void);
char *mc_config_get_full_path (const char *config_name);
/*** inline functions ****************************************************************************/ /*** inline functions ****************************************************************************/

View File

@ -60,7 +60,7 @@ static const struct
char **new_basedir; char **new_basedir;
const char *new_filename; const char *new_filename;
} mc_config_migrate_rules[] = } mc_config_files_reference[] =
{ {
/* *INDENT-OFF* */ /* *INDENT-OFF* */
/* config */ /* config */
@ -74,8 +74,9 @@ static const struct
{ "cedit" PATH_SEP_STR "edit.indent.rc", &mc_config_str, EDIT_DIR PATH_SEP_STR "edit.indent.rc"}, { "cedit" PATH_SEP_STR "edit.indent.rc", &mc_config_str, EDIT_DIR PATH_SEP_STR "edit.indent.rc"},
{ "cedit" PATH_SEP_STR "edit.spell.rc", &mc_config_str, EDIT_DIR PATH_SEP_STR "edit.spell.rc"}, { "cedit" PATH_SEP_STR "edit.spell.rc", &mc_config_str, EDIT_DIR PATH_SEP_STR "edit.spell.rc"},
{ "panels.ini", &mc_config_str, MC_PANELS_FILE}, { "panels.ini", &mc_config_str, MC_PANELS_FILE},
/* User should move this file with applying some changes in file */ /* User should move this file with applying some changes in file */
/* { "bindings", &mc_config_str, MC_FILEBIND_FILE}, */ { "", &mc_config_str, MC_FILEBIND_FILE},
/* data */ /* data */
{ "skins", &mc_data_str, MC_SKINS_SUBDIR}, { "skins", &mc_data_str, MC_SKINS_SUBDIR},
@ -86,6 +87,7 @@ static const struct
{ "history", &mc_data_str, MC_HISTORY_FILE}, { "history", &mc_data_str, MC_HISTORY_FILE},
{ "filepos", &mc_data_str, MC_FILEPOS_FILE}, { "filepos", &mc_data_str, MC_FILEPOS_FILE},
{ "cedit" PATH_SEP_STR "cooledit.clip", &mc_data_str, EDIT_CLIP_FILE}, { "cedit" PATH_SEP_STR "cooledit.clip", &mc_data_str, EDIT_CLIP_FILE},
{ "", &mc_data_str, MC_MACRO_FILE},
/* cache */ /* cache */
{ "log", &mc_cache_str, "mc.log"}, { "log", &mc_cache_str, "mc.log"},
@ -239,7 +241,7 @@ mc_config_fix_migrated_rules (void)
char *new_name; char *new_name;
new_name = g_build_filename (*mc_config_migrate_rules_fix[rule_index].new_basedir, new_name = g_build_filename (*mc_config_migrate_rules_fix[rule_index].new_basedir,
mc_config_migrate_rules[rule_index].new_filename, NULL); mc_config_files_reference[rule_index].new_filename, NULL);
rename (old_name, new_name); rename (old_name, new_name);
@ -394,19 +396,21 @@ mc_config_migrate_from_old_place (GError ** error)
g_free (mc_config_init_one_config_path (mc_data_str, EDIT_DIR, error)); g_free (mc_config_init_one_config_path (mc_data_str, EDIT_DIR, error));
#endif /* MC_HOMEDIR_XDG */ #endif /* MC_HOMEDIR_XDG */
for (rule_index = 0; mc_config_migrate_rules[rule_index].old_filename != NULL; rule_index++) for (rule_index = 0; mc_config_files_reference[rule_index].old_filename != NULL; rule_index++)
{ {
char *old_name; char *old_name;
if (*mc_config_files_reference[rule_index].old_filename == '\0')
continue;
old_name = old_name =
g_build_filename (old_dir, mc_config_migrate_rules[rule_index].old_filename, NULL); g_build_filename (old_dir, mc_config_files_reference[rule_index].old_filename, NULL);
if (g_file_test (old_name, G_FILE_TEST_EXISTS)) if (g_file_test (old_name, G_FILE_TEST_EXISTS))
{ {
char *new_name; char *new_name;
new_name = g_build_filename (*mc_config_migrate_rules[rule_index].new_basedir, new_name = g_build_filename (*mc_config_files_reference[rule_index].new_basedir,
mc_config_migrate_rules[rule_index].new_filename, NULL); mc_config_files_reference[rule_index].new_filename, NULL);
mc_config_copy (old_name, new_name, error); mc_config_copy (old_name, new_name, error);
@ -451,3 +455,30 @@ mc_config_deprecated_dir_present (void)
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
/**
* Get full path to config file by short name.
*
* @param config_name short name
* @return full path to config file
*/
char *
mc_config_get_full_path (const char *config_name)
{
size_t rule_index;
if (config_name == NULL)
return NULL;
for (rule_index = 0; mc_config_files_reference[rule_index].old_filename != NULL; rule_index++)
{
if (strcmp (config_name, mc_config_files_reference[rule_index].new_filename) == 0)
{
return g_build_filename (*mc_config_files_reference[rule_index].new_basedir,
mc_config_files_reference[rule_index].new_filename, NULL);
}
}
return NULL;
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -1277,7 +1277,7 @@ load_file_position (const char *filename, long *line, long *column, off_t * offs
*offset = 0; *offset = 0;
/* open file with positions */ /* open file with positions */
fn = g_build_filename (mc_config_get_cache_path (), MC_FILEPOS_FILE, NULL); fn = mc_config_get_full_path (MC_FILEPOS_FILE);
f = fopen (fn, "r"); f = fopen (fn, "r");
g_free (fn); g_free (fn);
if (f == NULL) if (f == NULL)
@ -1367,7 +1367,7 @@ save_file_position (const char *filename, long line, long column, off_t offset,
filepos_max_saved_entries = mc_config_get_int (mc_main_config, CONFIG_APP_SECTION, filepos_max_saved_entries = mc_config_get_int (mc_main_config, CONFIG_APP_SECTION,
"filepos_max_saved_entries", 1024); "filepos_max_saved_entries", 1024);
fn = g_build_filename (mc_config_get_cache_path (), MC_FILEPOS_FILE, NULL); fn = mc_config_get_full_path (MC_FILEPOS_FILE);
if (fn == NULL) if (fn == NULL)
goto early_error; goto early_error;

View File

@ -165,7 +165,7 @@ dlg_read_history (Dlg_head * h)
if (num_history_items_recorded == 0) /* this is how to disable */ if (num_history_items_recorded == 0) /* this is how to disable */
return; return;
profile = g_build_filename (mc_config_get_cache_path (), MC_HISTORY_FILE, NULL); profile = mc_config_get_full_path (MC_HISTORY_FILE);
event_data.cfg = mc_config_init (profile); event_data.cfg = mc_config_init (profile);
event_data.receiver = NULL; event_data.receiver = NULL;
@ -1192,7 +1192,7 @@ dlg_save_history (Dlg_head * h)
if (num_history_items_recorded == 0) /* this is how to disable */ if (num_history_items_recorded == 0) /* this is how to disable */
return; return;
profile = g_build_filename (mc_config_get_cache_path (), MC_HISTORY_FILE, (char *) NULL); profile = mc_config_get_full_path (MC_HISTORY_FILE);
i = open (profile, O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); i = open (profile, O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
if (i != -1) if (i != -1)
close (i); close (i);

View File

@ -150,7 +150,7 @@ history_get (const char *input_name)
if ((input_name == NULL) || (*input_name == '\0')) if ((input_name == NULL) || (*input_name == '\0'))
return NULL; return NULL;
profile = g_build_filename (mc_config_get_cache_path (), MC_HISTORY_FILE, NULL); profile = mc_config_get_full_path (MC_HISTORY_FILE);
cfg = mc_config_init (profile); cfg = mc_config_init (profile);
hist = history_load (cfg, input_name); hist = history_load (cfg, input_name);
@ -303,7 +303,7 @@ history_put (const char *input_name, GList * h)
if (h == NULL) if (h == NULL)
return; return;
profile = g_build_filename (mc_config_get_cache_path (), MC_HISTORY_FILE, (char *) NULL); profile = mc_config_get_full_path (MC_HISTORY_FILE);
i = open (profile, O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); i = open (profile, O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
if (i != -1) if (i != -1)

View File

@ -77,7 +77,7 @@ clipboard_file_to_ext_clip (const gchar * event_group_name, const gchar * event_
if (d == NULL || clipboard_store_path == NULL || clipboard_store_path[0] == '\0') if (d == NULL || clipboard_store_path == NULL || clipboard_store_path[0] == '\0')
return TRUE; return TRUE;
tmp = concat_dir_and_file (mc_config_get_cache_path (), EDIT_CLIP_FILE); tmp = mc_config_get_full_path (EDIT_CLIP_FILE);
cmd = g_strconcat (clipboard_store_path, " ", tmp, " 2>/dev/null", (char *) NULL); cmd = g_strconcat (clipboard_store_path, " ", tmp, " 2>/dev/null", (char *) NULL);
if (cmd != NULL) if (cmd != NULL)
@ -107,7 +107,7 @@ clipboard_file_from_ext_clip (const gchar * event_group_name, const gchar * even
if (d == NULL || clipboard_paste_path == NULL || clipboard_paste_path[0] == '\0') if (d == NULL || clipboard_paste_path == NULL || clipboard_paste_path[0] == '\0')
return TRUE; return TRUE;
tmp = concat_dir_and_file (mc_config_get_cache_path (), EDIT_CLIP_FILE); tmp = mc_config_get_full_path (EDIT_CLIP_FILE);
cmd = g_strconcat (clipboard_paste_path, " > ", tmp, " 2>/dev/null", (char *) NULL); cmd = g_strconcat (clipboard_paste_path, " > ", tmp, " 2>/dev/null", (char *) NULL);
if (cmd != NULL) if (cmd != NULL)
@ -138,7 +138,7 @@ clipboard_text_to_file (const gchar * event_group_name, const gchar * event_name
if (text == NULL) if (text == NULL)
return FALSE; return FALSE;
fname = g_build_filename (mc_config_get_cache_path (), EDIT_CLIP_FILE, NULL); fname = mc_config_get_full_path (EDIT_CLIP_FILE);
file = mc_open (fname, O_CREAT | O_WRONLY | O_TRUNC, file = mc_open (fname, O_CREAT | O_WRONLY | O_TRUNC,
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH | O_BINARY); S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH | O_BINARY);
g_free (fname); g_free (fname);
@ -169,7 +169,7 @@ clipboard_text_from_file (const gchar * event_group_name, const gchar * event_na
(void) event_name; (void) event_name;
(void) init_data; (void) init_data;
fname = g_build_filename (mc_config_get_cache_path (), EDIT_CLIP_FILE, NULL); fname = mc_config_get_full_path (EDIT_CLIP_FILE);
f = fopen (fname, "r"); f = fopen (fname, "r");
g_free (fname); g_free (fname);

View File

@ -714,10 +714,10 @@ edit_get_prev_utf (WEdit * edit, long byte_index, int *char_width)
cursor_buf_ptr = utf8_buf + (2 * UTF8_CHAR_LEN); cursor_buf_ptr = utf8_buf + (2 * UTF8_CHAR_LEN);
str = g_utf8_find_prev_char (utf8_buf, cursor_buf_ptr); str = g_utf8_find_prev_char (utf8_buf, cursor_buf_ptr);
if (str == NULL || g_utf8_next_char(str) != cursor_buf_ptr) if (str == NULL || g_utf8_next_char (str) != cursor_buf_ptr)
{ {
*char_width = 1; *char_width = 1;
return *(cursor_buf_ptr-1); return *(cursor_buf_ptr - 1);
} }
else else
{ {
@ -726,7 +726,7 @@ edit_get_prev_utf (WEdit * edit, long byte_index, int *char_width)
if (res < 0) if (res < 0)
{ {
*char_width = 1; *char_width = 1;
return *(cursor_buf_ptr-1); return *(cursor_buf_ptr - 1);
} }
else else
{ {
@ -1833,7 +1833,7 @@ user_menu (WEdit * edit, const char *menu_file, int selected_entry)
long start_mark, end_mark; long start_mark, end_mark;
struct stat status; struct stat status;
block_file = concat_dir_and_file (mc_config_get_cache_path (), EDIT_BLOCK_FILE); block_file = mc_config_get_full_path (EDIT_BLOCK_FILE);
curs = edit->curs1; curs = edit->curs1;
nomark = eval_marks (edit, &start_mark, &end_mark); nomark = eval_marks (edit, &start_mark, &end_mark);
if (nomark == 0) if (nomark == 0)

View File

@ -525,7 +525,7 @@ edit_load_syntax_file (WEdit * edit)
{ {
char *buffer; char *buffer;
buffer = concat_dir_and_file (mc_config_get_data_path (), EDIT_SYNTAX_FILE); buffer = mc_config_get_full_path (EDIT_SYNTAX_FILE);
check_for_default (extdir, buffer); check_for_default (extdir, buffer);
edit_load_file_from_filename (edit, buffer); edit_load_file_from_filename (edit, buffer);
g_free (buffer); g_free (buffer);
@ -566,7 +566,7 @@ edit_load_menu_file (WEdit * edit)
break; break;
case 1: case 1:
buffer = concat_dir_and_file (mc_config_get_data_path (), EDIT_HOME_MENU); buffer = mc_config_get_full_path (EDIT_HOME_MENU);
check_for_default (menufile, buffer); check_for_default (menufile, buffer);
break; break;
@ -937,7 +937,7 @@ edit_save_block_to_clip_file (WEdit * edit, long start, long finish)
{ {
int ret; int ret;
gchar *tmp; gchar *tmp;
tmp = concat_dir_and_file (mc_config_get_cache_path (), EDIT_CLIP_FILE); tmp = mc_config_get_full_path (EDIT_CLIP_FILE);
ret = edit_save_block (edit, tmp, start, finish); ret = edit_save_block (edit, tmp, start, finish);
g_free (tmp); g_free (tmp);
return ret; return ret;
@ -1311,7 +1311,7 @@ edit_delete_macro (WEdit * edit, int hotkey)
edit_macro_sort_by_hotkey (); edit_macro_sort_by_hotkey ();
} }
macros_fname = g_build_filename (mc_config_get_data_path (), MC_MACRO_FILE, (char *) NULL); macros_fname = mc_config_get_full_path (MC_MACRO_FILE);
macros_config = mc_config_init (macros_fname); macros_config = mc_config_init (macros_fname);
g_free (macros_fname); g_free (macros_fname);
@ -1645,7 +1645,7 @@ edit_store_macro_cmd (WEdit * edit)
edit_delete_macro (edit, hotkey); edit_delete_macro (edit, hotkey);
macros_fname = g_build_filename (mc_config_get_data_path (), MC_MACRO_FILE, (char *) NULL); macros_fname = mc_config_get_full_path (MC_MACRO_FILE);
macros_config = mc_config_init (macros_fname); macros_config = mc_config_init (macros_fname);
g_free (macros_fname); g_free (macros_fname);
@ -1749,7 +1749,7 @@ edit_load_macro_cmd (WEdit * edit)
(void) edit; (void) edit;
macros_fname = g_build_filename (mc_config_get_data_path (), MC_MACRO_FILE, (char *) NULL); macros_fname = mc_config_get_full_path (MC_MACRO_FILE);
macros_config = mc_config_init (macros_fname); macros_config = mc_config_init (macros_fname);
g_free (macros_fname); g_free (macros_fname);
@ -2683,7 +2683,7 @@ edit_paste_from_X_buf_cmd (WEdit * edit)
gchar *tmp; gchar *tmp;
/* try use external clipboard utility */ /* try use external clipboard utility */
mc_event_raise (MCEVENT_GROUP_CORE, "clipboard_file_from_ext_clip", NULL); mc_event_raise (MCEVENT_GROUP_CORE, "clipboard_file_from_ext_clip", NULL);
tmp = concat_dir_and_file (mc_config_get_cache_path (), EDIT_CLIP_FILE); tmp = mc_config_get_full_path (EDIT_CLIP_FILE);
edit_insert_file (edit, tmp); edit_insert_file (edit, tmp);
g_free (tmp); g_free (tmp);
} }
@ -2744,7 +2744,7 @@ edit_save_block_cmd (WEdit * edit)
if (eval_marks (edit, &start_mark, &end_mark)) if (eval_marks (edit, &start_mark, &end_mark))
return 1; return 1;
tmp = concat_dir_and_file (mc_config_get_cache_path (), EDIT_CLIP_FILE); tmp = mc_config_get_full_path (EDIT_CLIP_FILE);
exp = exp =
input_expand_dialog (_("Save block"), _("Enter file name:"), input_expand_dialog (_("Save block"), _("Enter file name:"),
MC_HISTORY_EDIT_SAVE_BLOCK, tmp); MC_HISTORY_EDIT_SAVE_BLOCK, tmp);
@ -2786,7 +2786,7 @@ edit_insert_file_cmd (WEdit * edit)
gchar *tmp; gchar *tmp;
char *exp; char *exp;
tmp = concat_dir_and_file (mc_config_get_cache_path (), EDIT_CLIP_FILE); tmp = mc_config_get_full_path (EDIT_CLIP_FILE);
exp = input_expand_dialog (_("Insert file"), _("Enter file name:"), exp = input_expand_dialog (_("Insert file"), _("Enter file name:"),
MC_HISTORY_EDIT_INSERT_FILE, tmp); MC_HISTORY_EDIT_INSERT_FILE, tmp);
g_free (tmp); g_free (tmp);
@ -2824,7 +2824,7 @@ int
edit_sort_cmd (WEdit * edit) edit_sort_cmd (WEdit * edit)
{ {
static char *old = 0; static char *old = 0;
char *exp, *tmp; char *exp, *tmp, *tmp_edit_block_name, *tmp_edit_temp_name;
long start_mark, end_mark; long start_mark, end_mark;
int e; int e;
@ -2834,7 +2834,7 @@ edit_sort_cmd (WEdit * edit)
return 0; return 0;
} }
tmp = concat_dir_and_file (mc_config_get_cache_path (), EDIT_BLOCK_FILE); tmp = mc_config_get_full_path (EDIT_BLOCK_FILE);
edit_save_block (edit, tmp, start_mark, end_mark); edit_save_block (edit, tmp, start_mark, end_mark);
g_free (tmp); g_free (tmp);
@ -2846,10 +2846,14 @@ edit_sort_cmd (WEdit * edit)
return 1; return 1;
g_free (old); g_free (old);
old = exp; old = exp;
tmp_edit_block_name = mc_config_get_full_path (EDIT_BLOCK_FILE);
tmp_edit_temp_name = mc_config_get_full_path (EDIT_TEMP_FILE);
tmp = tmp =
g_strconcat (" sort ", exp, " ", mc_config_get_cache_path (), PATH_SEP_STR EDIT_BLOCK_FILE, g_strconcat (" sort ", exp, " ", tmp_edit_block_name,
" > ", mc_config_get_cache_path (), PATH_SEP_STR EDIT_TEMP_FILE, " > ", tmp_edit_temp_name, (char *) NULL);
(char *) NULL); g_free (tmp_edit_temp_name);
g_free (tmp_edit_block_name);
e = system (tmp); e = system (tmp);
g_free (tmp); g_free (tmp);
if (e) if (e)
@ -2873,7 +2877,7 @@ edit_sort_cmd (WEdit * edit)
if (edit_block_delete_cmd (edit)) if (edit_block_delete_cmd (edit))
return 1; return 1;
tmp = concat_dir_and_file (mc_config_get_cache_path (), EDIT_TEMP_FILE); tmp = mc_config_get_full_path (EDIT_TEMP_FILE);
edit_insert_file (edit, tmp); edit_insert_file (edit, tmp);
g_free (tmp); g_free (tmp);
return 0; return 0;
@ -2888,7 +2892,7 @@ edit_sort_cmd (WEdit * edit)
int int
edit_ext_cmd (WEdit * edit) edit_ext_cmd (WEdit * edit)
{ {
char *exp, *tmp; char *exp, *tmp, *tmp_edit_temp_file;
int e; int e;
exp = exp =
@ -2898,9 +2902,9 @@ edit_ext_cmd (WEdit * edit)
if (!exp) if (!exp)
return 1; return 1;
tmp = tmp_edit_temp_file = mc_config_get_full_path (EDIT_TEMP_FILE);
g_strconcat (exp, " > ", mc_config_get_cache_path (), PATH_SEP_STR EDIT_TEMP_FILE, tmp = g_strconcat (exp, " > ", tmp_edit_temp_file, (char *) NULL);
(char *) NULL); g_free (tmp_edit_temp_file);
e = system (tmp); e = system (tmp);
g_free (tmp); g_free (tmp);
g_free (exp); g_free (exp);
@ -2912,7 +2916,7 @@ edit_ext_cmd (WEdit * edit)
} }
edit->force |= REDRAW_COMPLETELY; edit->force |= REDRAW_COMPLETELY;
tmp = concat_dir_and_file (mc_config_get_cache_path (), EDIT_TEMP_FILE); tmp = mc_config_get_full_path (EDIT_TEMP_FILE);
edit_insert_file (edit, tmp); edit_insert_file (edit, tmp);
g_free (tmp); g_free (tmp);
return 0; return 0;

View File

@ -1512,7 +1512,7 @@ edit_load_syntax (WEdit * edit, char ***pnames, const char *type)
if (!*edit->filename && !type) if (!*edit->filename && !type)
return; return;
} }
f = g_build_filename (mc_config_get_data_path (), EDIT_SYNTAX_FILE, (char *) NULL); f = mc_config_get_full_path (EDIT_SYNTAX_FILE);
if (edit != NULL) if (edit != NULL)
r = edit_read_syntax_file (edit, pnames, f, edit->filename, r = edit_read_syntax_file (edit, pnames, f, edit->filename,
get_first_editor_line (edit), get_first_editor_line (edit),

View File

@ -1069,7 +1069,7 @@ ext_cmd (void)
if (dir == 0) if (dir == 0)
{ {
buffer = g_build_filename (mc_config_get_data_path (), MC_FILEBIND_FILE, NULL); buffer = mc_config_get_full_path (MC_FILEBIND_FILE);
check_for_default (extdir, buffer); check_for_default (extdir, buffer);
do_edit (buffer); do_edit (buffer);
g_free (buffer); g_free (buffer);
@ -1118,7 +1118,7 @@ edit_mc_menu_cmd (void)
break; break;
case 1: case 1:
buffer = g_build_filename (mc_config_get_data_path (), MC_USERMENU_FILE, NULL); buffer = mc_config_get_full_path (MC_USERMENU_FILE);
check_for_default (menufile, buffer); check_for_default (menufile, buffer);
break; break;
@ -1163,7 +1163,7 @@ edit_fhl_cmd (void)
if (dir == 0) if (dir == 0)
{ {
buffer = g_build_filename (mc_config_get_path (), MC_FHL_INI_FILE, NULL); buffer = mc_config_get_full_path (MC_FHL_INI_FILE);
check_for_default (fhlfile, buffer); check_for_default (fhlfile, buffer);
do_edit (buffer); do_edit (buffer);
g_free (buffer); g_free (buffer);
@ -1615,7 +1615,7 @@ save_setup_cmd (void)
char *d1; char *d1;
const char *d2; const char *d2;
d1 = g_build_filename (mc_config_get_path (), MC_CONFIG_FILE, (char *) NULL); d1 = mc_config_get_full_path (MC_CONFIG_FILE);
d2 = strip_home_and_password (d1); d2 = strip_home_and_password (d1);
g_free (d1); g_free (d1);

View File

@ -641,7 +641,7 @@ regex_command (const char *filename, const char *action, int *move_dir)
int mc_user_ext = 1; int mc_user_ext = 1;
int home_error = 0; int home_error = 0;
extension_file = g_build_filename (mc_config_get_data_path (), MC_FILEBIND_FILE, NULL); extension_file = mc_config_get_full_path (MC_FILEBIND_FILE);
if (!exist_file (extension_file)) if (!exist_file (extension_file))
{ {
g_free (extension_file); g_free (extension_file);
@ -687,15 +687,14 @@ regex_command (const char *filename, const char *action, int *move_dir)
} }
if (home_error) if (home_error)
{ {
char *title = g_strdup_printf (_("%s%s%s file error"), char *filebind_filename = mc_config_get_full_path (MC_FILEBIND_FILE);
mc_config_get_data_path (), PATH_SEP_STR, char *title = g_strdup_printf (_("%s file error"), filebind_filename);
MC_FILEBIND_FILE);
message (D_ERROR, title, message (D_ERROR, title,
_("The format of the %s%s%s file has " _("The format of the %s file has "
"changed with version 3.0. You may either want to copy " "changed with version 3.0. You may either want to copy "
"it from %smc.ext or use that file as an example of how to write it."), "it from %smc.ext or use that file as an example of how to write it."),
mc_config_get_data_path (), PATH_SEP_STR, MC_FILEBIND_FILE, filebind_filename, mc_global.sysconfig_dir);
mc_global.sysconfig_dir); g_free (filebind_filename);
g_free (title); g_free (title);
} }
} }

View File

@ -1564,7 +1564,7 @@ load_hotlist (void)
} }
if (!hotlist_file_name) if (!hotlist_file_name)
hotlist_file_name = g_build_filename (mc_config_get_path (), MC_HOTLIST_FILE, NULL); hotlist_file_name = mc_config_get_full_path (MC_HOTLIST_FILE);
hotlist = new_hotlist (); hotlist = new_hotlist ();
hotlist->type = HL_TYPE_GROUP; hotlist->type = HL_TYPE_GROUP;

View File

@ -178,8 +178,7 @@ save_tree (WTree * tree)
if (error) if (error)
{ {
tree_name = tree_name = mc_config_get_full_path (MC_TREESTORE_FILE);
g_build_filename (mc_config_get_cache_path (), MC_TREESTORE_FILE, (char *) NULL);
fprintf (stderr, _("Cannot open the %s file for writing:\n%s\n"), tree_name, fprintf (stderr, _("Cannot open the %s file for writing:\n%s\n"), tree_name,
unix_error_string (error)); unix_error_string (error));
g_free (tree_name); g_free (tree_name);

View File

@ -647,7 +647,7 @@ tree_store_load (void)
char *name; char *name;
int retval; int retval;
name = g_build_filename (mc_config_get_cache_path (), MC_TREESTORE_FILE, NULL); name = mc_config_get_full_path (MC_TREESTORE_FILE);
retval = tree_store_load_from (name); retval = tree_store_load_from (name);
g_free (name); g_free (name);
@ -667,7 +667,7 @@ tree_store_save (void)
char *name; char *name;
int retval; int retval;
name = g_build_filename (mc_config_get_cache_path (), MC_TREESTORE_FILE, NULL); name = mc_config_get_full_path (MC_TREESTORE_FILE);
mc_util_make_backup_if_possible (name, ".tmp"); mc_util_make_backup_if_possible (name, ".tmp");
retval = tree_store_save_to (name); retval = tree_store_save_to (name);

View File

@ -798,7 +798,7 @@ expand_format (struct WEdit *edit_widget, char c, gboolean do_quote)
#ifdef USE_INTERNAL_EDIT #ifdef USE_INTERNAL_EDIT
if (edit_widget) if (edit_widget)
{ {
char *file = concat_dir_and_file (mc_config_get_cache_path (), EDIT_BLOCK_FILE); char *file = mc_config_get_full_path (EDIT_BLOCK_FILE);
fname = (*quote_func) (file, 0); fname = (*quote_func) (file, 0);
g_free (file); g_free (file);
return fname; return fname;
@ -897,9 +897,9 @@ user_menu_cmd (struct WEdit * edit_widget, const char *menu_file, int selected_e
g_free (menu); g_free (menu);
if (edit_widget) if (edit_widget)
menu = concat_dir_and_file (mc_config_get_data_path (), EDIT_HOME_MENU); menu = mc_config_get_full_path (EDIT_HOME_MENU);
else else
menu = g_build_filename (mc_config_get_data_path (), MC_USERMENU_FILE, NULL); menu = mc_config_get_full_path (MC_USERMENU_FILE);
if (!exist_file (menu)) if (!exist_file (menu))

View File

@ -621,8 +621,7 @@ load_keymap_from_section (const char *section_name, GArray * keymap, mc_config_t
{ {
gchar **values, **curr_values; gchar **values, **curr_values;
curr_values = values = curr_values = values = mc_config_get_string_list (cfg, section_name, *profile_keys, &len);
mc_config_get_string_list (cfg, section_name, *profile_keys, &len);
if (curr_values != NULL) if (curr_values != NULL)
{ {
@ -672,7 +671,7 @@ load_setup_get_keymap_profile_config (gboolean load_from_file)
g_free (fname); g_free (fname);
/* 3) ${XDG_CONFIG_HOME}/mc */ /* 3) ${XDG_CONFIG_HOME}/mc */
fname = g_build_filename (mc_config_get_path (), GLOBAL_KEYMAP_FILE, NULL); fname = mc_config_get_full_path (GLOBAL_KEYMAP_FILE);
load_setup_init_config_from_file (&keymap_config, fname); load_setup_init_config_from_file (&keymap_config, fname);
g_free (fname); g_free (fname);
@ -793,7 +792,7 @@ setup_init (void)
if (profile_name != NULL) if (profile_name != NULL)
return profile_name; return profile_name;
profile = g_build_filename (mc_config_get_path (), MC_CONFIG_FILE, NULL); profile = mc_config_get_full_path (MC_CONFIG_FILE);
if (!exist_file (profile)) if (!exist_file (profile))
{ {
inifile = concat_dir_and_file (mc_global.sysconfig_dir, "mc.ini"); inifile = concat_dir_and_file (mc_global.sysconfig_dir, "mc.ini");
@ -848,7 +847,7 @@ load_setup (void)
g_build_filename (mc_global.share_data_dir, MC_GLOBAL_CONFIG_FILE, (char *) NULL); g_build_filename (mc_global.share_data_dir, MC_GLOBAL_CONFIG_FILE, (char *) NULL);
} }
panels_profile_name = g_build_filename (mc_config_get_cache_path (), MC_PANELS_FILE, NULL); panels_profile_name = mc_config_get_full_path (MC_PANELS_FILE);
mc_main_config = mc_config_init (profile); mc_main_config = mc_config_init (profile);
@ -1005,7 +1004,7 @@ save_setup (gboolean save_options, gboolean save_panel_options)
mc_config_set_string (mc_main_config, "Misc", "clipboard_store", clipboard_store_path); mc_config_set_string (mc_main_config, "Misc", "clipboard_store", clipboard_store_path);
mc_config_set_string (mc_main_config, "Misc", "clipboard_paste", clipboard_paste_path); mc_config_set_string (mc_main_config, "Misc", "clipboard_paste", clipboard_paste_path);
tmp_profile = g_build_filename (mc_config_get_path (), MC_CONFIG_FILE, NULL); tmp_profile = mc_config_get_full_path (MC_CONFIG_FILE);
ret = mc_config_save_to_file (mc_main_config, tmp_profile, NULL); ret = mc_config_save_to_file (mc_main_config, tmp_profile, NULL);
g_free (tmp_profile); g_free (tmp_profile);
} }

View File

@ -269,7 +269,7 @@ init_subshell_child (const char *pty_name)
switch (subshell_type) switch (subshell_type)
{ {
case BASH: case BASH:
init_file = g_build_filename (mc_config_get_path (), "bashrc", NULL); init_file = mc_config_get_full_path ("bashrc");
if (access (init_file, R_OK) == -1) if (access (init_file, R_OK) == -1)
{ {
@ -282,7 +282,7 @@ init_subshell_child (const char *pty_name)
/* Allow alternative readline settings for MC */ /* Allow alternative readline settings for MC */
{ {
char *input_file = g_build_filename (mc_config_get_path (), "inputrc", NULL); char *input_file = mc_config_get_full_path ("inputrc");
if (access (input_file, R_OK) == 0) if (access (input_file, R_OK) == 0)
{ {
char *putenv_str = g_strconcat ("INPUTRC=", input_file, NULL); char *putenv_str = g_strconcat ("INPUTRC=", input_file, NULL);