(tree_chdir, sync_tree): take vfs_path_t object to avoid double conversion of path.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2016-01-31 12:05:09 +03:00
parent 387f41f9ce
commit a52cb840ae
5 changed files with 35 additions and 24 deletions

View File

@ -1108,11 +1108,17 @@ hotlist_cmd (void)
char *target;
target = hotlist_show (LIST_HOTLIST);
if (!target)
if (target == NULL)
return;
if (get_current_type () == view_tree)
tree_chdir (the_tree, target);
{
vfs_path_t *vpath;
vpath = vfs_path_from_str (target);
tree_chdir (the_tree, vpath);
vfs_path_free (vpath);
}
else
{
vfs_path_t *deprecated_vpath;

View File

@ -53,7 +53,7 @@
#include "midnight.h" /* current_panel */
#include "layout.h" /* for command_prompt variable */
#include "usermenu.h" /* expand_format */
#include "tree.h" /* for tree_chdir */
#include "tree.h" /* sync_tree() */
#include "command.h"
@ -401,9 +401,12 @@ do_cd_command (char *orig_cmd)
if (get_current_type () == view_tree)
{
if (cmd[0] == 0)
vfs_path_t *new_vpath = NULL;
if (cmd[0] == '\0')
{
sync_tree (mc_config_get_home_dir ());
new_vpath = vfs_path_from_str (mc_config_get_home_dir ());
sync_tree (new_vpath);
}
else if (DIR_IS_DOTDOT (cmd + operand_pos))
{
@ -416,18 +419,19 @@ do_cd_command (char *orig_cmd)
vfs_path_vtokens_get (tmp_vpath, 0, vfs_path_tokens_count (tmp_vpath) - 1);
vfs_path_free (tmp_vpath);
}
sync_tree (vfs_path_as_str (current_panel->cwd_vpath));
sync_tree (current_panel->cwd_vpath);
}
else if (IS_PATH_SEP (cmd[operand_pos]))
sync_tree (cmd + operand_pos);
else
{
vfs_path_t *new_vpath;
if (IS_PATH_SEP (cmd[operand_pos]))
new_vpath = vfs_path_from_str (cmd + operand_pos);
else
new_vpath = vfs_path_append_new (current_panel->cwd_vpath, cmd + operand_pos, NULL);
sync_tree (vfs_path_as_str (new_vpath));
vfs_path_free (new_vpath);
sync_tree (new_vpath);
}
vfs_path_free (new_vpath);
}
else
{

View File

@ -214,10 +214,14 @@ tree_destroy (WTree * tree)
static void
load_tree (WTree * tree)
{
vfs_path_t *vpath;
tree_store_load ();
tree->selected_ptr = tree->store->tree_first;
tree_chdir (tree, mc_config_get_home_dir ());
vpath = vfs_path_from_str (mc_config_get_home_dir ());
tree_chdir (tree, vpath);
vfs_path_free (vpath);
}
/* --------------------------------------------------------------------------------------------- */
@ -1283,19 +1287,16 @@ tree_new (int y, int x, int lines, int cols, gboolean is_panel)
/* --------------------------------------------------------------------------------------------- */
void
tree_chdir (WTree * tree, const char *dir)
tree_chdir (WTree * tree, const vfs_path_t * dir)
{
vfs_path_t *vpath;
tree_entry *current;
vpath = vfs_path_from_str (dir);
current = tree_store_whereis (vpath);
current = tree_store_whereis (dir);
if (current != NULL)
{
tree->selected_ptr = current;
tree_check_focus (tree);
}
vfs_path_free (vpath);
}
/* --------------------------------------------------------------------------------------------- */
@ -1310,9 +1311,9 @@ tree_selected_name (const WTree * tree)
/* --------------------------------------------------------------------------------------------- */
void
sync_tree (const char *path)
sync_tree (const vfs_path_t * vpath)
{
tree_chdir (the_tree, path);
tree_chdir (the_tree, vpath);
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -26,10 +26,10 @@ struct WDialog;
WTree *tree_new (int y, int x, int lines, int cols, gboolean is_panel);
void tree_chdir (WTree * tree, const char *dir);
void tree_chdir (WTree * tree, const vfs_path_t * dir);
const vfs_path_t *tree_selected_name (const WTree * tree);
void sync_tree (const char *pathname);
void sync_tree (const vfs_path_t * vpath);
WTree *find_tree (struct WDialog *h);

View File

@ -101,9 +101,9 @@ shell_execute (const char *command, int flags)
}
void
sync_tree (const char *pathname)
sync_tree (const vfs_path_t * vpath)
{
(void) pathname;
(void) vpath;
}
/* --------------------------------------------------------------------------------------------- */