mirror of https://github.com/MidnightCommander/mc
Code refactoring: removed concat_dir_and_file() function.
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
parent
862d53090d
commit
8562a215be
16
lib/util.c
16
lib/util.c
|
@ -1134,22 +1134,6 @@ diff_two_paths (const vfs_path_t * vpath1, const vfs_path_t * vpath2)
|
|||
return buf;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* If filename is NULL, then we just append PATH_SEP to the dir
|
||||
*/
|
||||
|
||||
char *
|
||||
concat_dir_and_file (const char *dir, const char *file)
|
||||
{
|
||||
int i = strlen (dir);
|
||||
|
||||
if (dir[i - 1] == PATH_SEP)
|
||||
return g_strconcat (dir, file, (char *) NULL);
|
||||
else
|
||||
return g_strconcat (dir, PATH_SEP_STR, file, (char *) NULL);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Append text to GList, remove all entries with the same text
|
||||
|
|
|
@ -116,7 +116,6 @@ char *strip_password (char *path, int has_prefix);
|
|||
const char *strip_home_and_password (const char *dir);
|
||||
|
||||
const char *extension (const char *);
|
||||
char *concat_dir_and_file (const char *dir, const char *file);
|
||||
const char *unix_error_string (int error_num);
|
||||
const char *skip_separators (const char *s);
|
||||
const char *skip_numbers (const char *s);
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
#include "lib/global.h"
|
||||
|
||||
#include "lib/tty/tty.h" /* enable/disable interrupt key */
|
||||
#include "lib/util.h" /* concat_dir_and_file */
|
||||
#include "lib/util.h" /* custom_canonicalize_pathname() */
|
||||
#if 0
|
||||
#include "lib/widget.h" /* message() */
|
||||
#endif
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
#include "lib/global.h"
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/util.h" /* concat_dir_and_file */
|
||||
#include "lib/util.h" /* mc_build_filename() */
|
||||
#include "lib/serialize.h"
|
||||
|
||||
#include "vfs.h"
|
||||
|
@ -143,7 +143,7 @@ vfs_canon (const char *path)
|
|||
char *local, *result, *curr_dir;
|
||||
|
||||
curr_dir = vfs_get_current_dir ();
|
||||
local = concat_dir_and_file (curr_dir, path);
|
||||
local = mc_build_filename (curr_dir, path, NULL);
|
||||
g_free (curr_dir);
|
||||
|
||||
result = vfs_canon (local);
|
||||
|
|
|
@ -646,7 +646,7 @@ command_completion_function (const char *_text, int state, input_complete_t flag
|
|||
if (cur_path >= path_end)
|
||||
break;
|
||||
expanded = tilde_expand (*cur_path ? cur_path : ".");
|
||||
cur_word = concat_dir_and_file (expanded, text);
|
||||
cur_word = mc_build_filename (expanded, text, NULL);
|
||||
g_free (expanded);
|
||||
canonicalize_pathname (cur_word);
|
||||
cur_path = strchr (cur_path, 0) + 1;
|
||||
|
@ -986,7 +986,7 @@ try_complete (char *text, int *lc_start, int *lc_end, input_complete_t flags)
|
|||
*s = 0;
|
||||
if (*cdpath)
|
||||
{
|
||||
r = concat_dir_and_file (cdpath, word);
|
||||
r = mc_build_filename (cdpath, word, NULL);
|
||||
SHOW_C_CTX ("try_complete:filename_subst_2");
|
||||
matches = completion_matches (r, filename_completion_function, flags);
|
||||
g_free (r);
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
#include "lib/tty/tty.h"
|
||||
#include "lib/skin.h" /* tty_set_normal_attrs */
|
||||
#include "lib/tty/win.h"
|
||||
#include "lib/util.h" /* concat_dir_and_file() */
|
||||
#include "lib/util.h" /* mc_build_filename() */
|
||||
|
||||
#include "consaver/cons.saver.h"
|
||||
|
||||
|
@ -205,7 +205,7 @@ handle_console_linux (console_action_t action)
|
|||
if (tty_name)
|
||||
{
|
||||
/* Exec the console save/restore handler */
|
||||
mc_conssaver = concat_dir_and_file (SAVERDIR, "cons.saver");
|
||||
mc_conssaver = mc_build_filename (SAVERDIR, "cons.saver", NULL);
|
||||
execl (mc_conssaver, "cons.saver", tty_name, (char *) NULL);
|
||||
}
|
||||
/* Console is not a tty or execl() failed */
|
||||
|
@ -383,8 +383,8 @@ console_save (void)
|
|||
for (i = 0; i < screen_shot.xsize * screen_shot.ysize; i++)
|
||||
{
|
||||
screen_shot.buf[i] =
|
||||
(screen_shot.buf[i] & 0xff00) | (unsigned char) revmap.scrmap[screen_shot.
|
||||
buf[i] & 0xff];
|
||||
(screen_shot.buf[i] & 0xff00) | (unsigned char) revmap.
|
||||
scrmap[screen_shot.buf[i] & 0xff];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
#include "lib/tty/color.h" /* tty_setcolor() */
|
||||
#include "lib/skin.h" /* EDITOR_NORMAL_COLOR */
|
||||
#include "lib/strutil.h" /* str_term_trim() */
|
||||
#include "lib/util.h" /* concat_dir_and_file() */
|
||||
#include "lib/util.h" /* mc_build_filename() */
|
||||
#include "lib/widget.h"
|
||||
#include "lib/mcconfig.h"
|
||||
|
||||
|
@ -366,15 +366,17 @@ edit_file (const vfs_path_t * _file_vpath, int line)
|
|||
|
||||
if (!made_directory)
|
||||
{
|
||||
char *dir = concat_dir_and_file (mc_config_get_cache_path (), EDIT_DIR);
|
||||
char *dir;
|
||||
|
||||
dir = mc_build_filename (mc_config_get_cache_path (), EDIT_DIR, NULL);
|
||||
made_directory = (mkdir (dir, 0700) != -1 || errno == EEXIST);
|
||||
g_free (dir);
|
||||
|
||||
dir = concat_dir_and_file (mc_config_get_path (), EDIT_DIR);
|
||||
dir = mc_build_filename (mc_config_get_path (), EDIT_DIR, NULL);
|
||||
made_directory = (mkdir (dir, 0700) != -1 || errno == EEXIST);
|
||||
g_free (dir);
|
||||
|
||||
dir = concat_dir_and_file (mc_config_get_data_path (), EDIT_DIR);
|
||||
dir = mc_build_filename (mc_config_get_data_path (), EDIT_DIR, NULL);
|
||||
made_directory = (mkdir (dir, 0700) != -1 || errno == EEXIST);
|
||||
g_free (dir);
|
||||
}
|
||||
|
|
|
@ -662,11 +662,11 @@ regex_command (const char *filename, const char *action, int *move_dir)
|
|||
{
|
||||
g_free (extension_file);
|
||||
check_stock_mc_ext:
|
||||
extension_file = concat_dir_and_file (mc_global.sysconfig_dir, MC_LIB_EXT);
|
||||
extension_file = mc_build_filename (mc_global.sysconfig_dir, MC_LIB_EXT, NULL);
|
||||
if (!exist_file (extension_file))
|
||||
{
|
||||
g_free (extension_file);
|
||||
extension_file = concat_dir_and_file (mc_global.share_data_dir, MC_LIB_EXT);
|
||||
extension_file = mc_build_filename (mc_global.share_data_dir, MC_LIB_EXT, NULL);
|
||||
}
|
||||
mc_user_ext = 0;
|
||||
}
|
||||
|
|
|
@ -1045,7 +1045,7 @@ recursive_erase (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s)
|
|||
continue;
|
||||
if (!strcmp (next->d_name, ".."))
|
||||
continue;
|
||||
path = concat_dir_and_file (s, next->d_name);
|
||||
path = mc_build_filename (s, next->d_name, NULL);
|
||||
tmp_vpath = vfs_path_from_str (path);
|
||||
if (mc_lstat (tmp_vpath, &buf) != 0)
|
||||
{
|
||||
|
@ -2047,7 +2047,7 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
|
|||
/* Dive into subdir if exists */
|
||||
if (toplevel && ctx->dive_into_subdirs)
|
||||
{
|
||||
dest_dir = concat_dir_and_file (d, x_basename (s));
|
||||
dest_dir = mc_build_filename (d, x_basename (s), NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2116,7 +2116,7 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
|
|||
continue;
|
||||
|
||||
/* get the filename and add it to the src directory */
|
||||
path = concat_dir_and_file (s, next->d_name);
|
||||
path = mc_build_filename (s, next->d_name, NULL);
|
||||
tmp_vpath = vfs_path_from_str (path);
|
||||
|
||||
(*ctx->stat_func) (tmp_vpath, &buf);
|
||||
|
@ -2124,7 +2124,7 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
|
|||
{
|
||||
char *mdpath;
|
||||
|
||||
mdpath = concat_dir_and_file (dest_dir, next->d_name);
|
||||
mdpath = mc_build_filename (dest_dir, next->d_name, NULL);
|
||||
/*
|
||||
* From here, we just intend to recursively copy subdirs, not
|
||||
* the double functionality of copying different when the target
|
||||
|
@ -2139,7 +2139,7 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
|
|||
{
|
||||
char *dest_file;
|
||||
|
||||
dest_file = concat_dir_and_file (dest_dir, x_basename (path));
|
||||
dest_file = mc_build_filename (dest_dir, x_basename (path), NULL);
|
||||
return_status = copy_file_file (tctx, ctx, path, dest_file);
|
||||
g_free (dest_file);
|
||||
}
|
||||
|
@ -2243,7 +2243,7 @@ move_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
|
|||
move_over = TRUE;
|
||||
}
|
||||
else
|
||||
destdir = concat_dir_and_file (d, x_basename (s));
|
||||
destdir = mc_build_filename (d, x_basename (s), NULL);
|
||||
|
||||
destdir_vpath = vfs_path_from_str (destdir);
|
||||
|
||||
|
@ -2859,7 +2859,7 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl
|
|||
char *repl_dest, *temp2;
|
||||
|
||||
repl_dest = mc_search_prepare_replace_str2 (ctx->search_handle, dest);
|
||||
temp2 = concat_dir_and_file (repl_dest, temp);
|
||||
temp2 = mc_build_filename (repl_dest, temp, NULL);
|
||||
g_free (temp);
|
||||
g_free (repl_dest);
|
||||
g_free (dest);
|
||||
|
@ -2960,7 +2960,7 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl
|
|||
char *temp2, *temp3, *repl_dest;
|
||||
|
||||
repl_dest = mc_search_prepare_replace_str2 (ctx->search_handle, dest);
|
||||
temp2 = concat_dir_and_file (repl_dest, temp);
|
||||
temp2 = mc_build_filename (repl_dest, temp, NULL);
|
||||
g_free (temp);
|
||||
g_free (repl_dest);
|
||||
temp3 = source_with_path_str;
|
||||
|
|
|
@ -105,7 +105,7 @@ my_mkdir_rec (char *s, mode_t mode)
|
|||
return -1;
|
||||
}
|
||||
|
||||
p = concat_dir_and_file (s, "..");
|
||||
p = mc_build_filename (s, "..", NULL);
|
||||
{
|
||||
vfs_path_t *vpath;
|
||||
|
||||
|
|
|
@ -2506,7 +2506,7 @@ do_enter_on_file_entry (file_entry * fe)
|
|||
char *tmp_path;
|
||||
|
||||
tmp_path = vfs_path_to_str (current_panel->cwd_vpath);
|
||||
full_name = concat_dir_and_file (tmp_path, fe->fname);
|
||||
full_name = mc_build_filename (tmp_path, fe->fname, NULL);
|
||||
g_free (tmp_path);
|
||||
}
|
||||
if (!is_exe (fe->st.st_mode) || !if_link_is_exe (full_name, fe))
|
||||
|
@ -2677,7 +2677,7 @@ chdir_to_readlink (WPanel * panel)
|
|||
char *tmp_path;
|
||||
|
||||
tmp_path = vfs_path_to_str (panel->cwd_vpath);
|
||||
new_dir = concat_dir_and_file (tmp_path, buffer);
|
||||
new_dir = mc_build_filename (tmp_path, buffer, NULL);
|
||||
g_free (tmp_path);
|
||||
}
|
||||
|
||||
|
|
|
@ -954,19 +954,20 @@ user_menu_cmd (struct WEdit * edit_widget, const char *menu_file, int selected_e
|
|||
{
|
||||
g_free (menu);
|
||||
menu =
|
||||
concat_dir_and_file (mc_config_get_home_dir (),
|
||||
edit_widget ? EDIT_GLOBAL_MENU : MC_GLOBAL_MENU);
|
||||
mc_build_filename (mc_config_get_home_dir (),
|
||||
edit_widget ? EDIT_GLOBAL_MENU : MC_GLOBAL_MENU, NULL);
|
||||
if (!exist_file (menu))
|
||||
{
|
||||
g_free (menu);
|
||||
menu =
|
||||
concat_dir_and_file (mc_global.sysconfig_dir,
|
||||
edit_widget ? EDIT_GLOBAL_MENU : MC_GLOBAL_MENU);
|
||||
mc_build_filename (mc_global.sysconfig_dir,
|
||||
edit_widget ? EDIT_GLOBAL_MENU : MC_GLOBAL_MENU, NULL);
|
||||
if (!exist_file (menu))
|
||||
{
|
||||
g_free (menu);
|
||||
menu = concat_dir_and_file
|
||||
(mc_global.share_data_dir, edit_widget ? EDIT_GLOBAL_MENU : MC_GLOBAL_MENU);
|
||||
menu = mc_build_filename
|
||||
(mc_global.share_data_dir, edit_widget ? EDIT_GLOBAL_MENU : MC_GLOBAL_MENU,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -827,7 +827,7 @@ setup_init (void)
|
|||
profile = mc_config_get_full_path (MC_CONFIG_FILE);
|
||||
if (!exist_file (profile))
|
||||
{
|
||||
inifile = concat_dir_and_file (mc_global.sysconfig_dir, "mc.ini");
|
||||
inifile = mc_build_filename (mc_global.sysconfig_dir, "mc.ini", NULL);
|
||||
if (exist_file (inifile))
|
||||
{
|
||||
g_free (profile);
|
||||
|
@ -836,7 +836,7 @@ setup_init (void)
|
|||
else
|
||||
{
|
||||
g_free (inifile);
|
||||
inifile = concat_dir_and_file (mc_global.share_data_dir, "mc.ini");
|
||||
inifile = mc_build_filename (mc_global.share_data_dir, "mc.ini", NULL);
|
||||
if (exist_file (inifile))
|
||||
{
|
||||
g_free (profile);
|
||||
|
|
|
@ -65,7 +65,7 @@ What to do with this?
|
|||
int f = !strcmp( remote_path, "/~" );
|
||||
if (f || !strncmp( remote_path, "/~/", 3 )) {
|
||||
char *s;
|
||||
s = concat_dir_and_file( qhome (*bucket), remote_path +3-f );
|
||||
s = mc_build_filename ( qhome (*bucket), remote_path +3-f, NULL );
|
||||
g_free (remote_path);
|
||||
remote_path = s;
|
||||
}
|
||||
|
@ -1680,8 +1680,10 @@ ftpfs_dir_load (struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path
|
|||
sock = ftpfs_open_data_connection (me, super, "LIST -la", 0, TYPE_ASCII, 0);
|
||||
else
|
||||
{
|
||||
char *path;
|
||||
|
||||
/* Trailing "/." is necessary if remote_path is a symlink */
|
||||
char *path = concat_dir_and_file (remote_path, ".");
|
||||
path = mc_build_filename (remote_path, ".", NULL);
|
||||
sock = ftpfs_open_data_connection (me, super, "LIST -la", path, TYPE_ASCII, 0);
|
||||
g_free (path);
|
||||
}
|
||||
|
|
|
@ -1360,7 +1360,8 @@ smbfs_get_path (smbfs_connection ** sc, const vfs_path_t * vpath)
|
|||
if (f != 0 || strncmp (remote_path, "/~/", 3) == 0)
|
||||
{
|
||||
char *s;
|
||||
s = concat_dir_and_file ((*sc)->home, remote_path + 3 - f);
|
||||
|
||||
s = mc_build_filename ((*sc)->home, remote_path + 3 - f, NULL);
|
||||
g_free (remote_path);
|
||||
remote_path = s;
|
||||
}
|
||||
|
@ -1728,8 +1729,8 @@ smbfs_stat (const vfs_path_t * vpath, struct stat *buf)
|
|||
if (path_element->class != &vfs_smbfs_ops)
|
||||
return -1;
|
||||
|
||||
while (*p == '/') /* '/' leading server name */
|
||||
p++; /* probably came from server browsing */
|
||||
while (*p == '/') /* '/' leading server name */
|
||||
p++; /* probably came from server browsing */
|
||||
|
||||
pp = strchr (p, '/'); /* advance past next '/' */
|
||||
at = strchr (p, '@');
|
||||
|
|
Loading…
Reference in New Issue