Use vfs_path_as_str() to get string representation of tree_entry::name.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2013-07-13 20:18:13 +04:00
parent 4aacb0f33c
commit 1d52364b52
2 changed files with 38 additions and 18 deletions

View File

@ -257,7 +257,8 @@ tree_show_mini_info (WTree * tree, int tree_lines, int tree_cols)
tty_setcolor (tree->is_panel ? NORMAL_COLOR : TREE_NORMALC (h)); tty_setcolor (tree->is_panel ? NORMAL_COLOR : TREE_NORMALC (h));
tty_draw_hline (w->y + line, w->x + 1, ' ', tree_cols); tty_draw_hline (w->y + line, w->x + 1, ' ', tree_cols);
widget_move (w, line, 1); widget_move (w, line, 1);
tty_print_string (str_fit_to_term (tree->selected_ptr->name->str, tree_cols, J_LEFT_FIT)); tty_print_string (str_fit_to_term
(vfs_path_as_str (tree->selected_ptr->name), tree_cols, J_LEFT_FIT));
} }
} }
@ -316,7 +317,11 @@ show_tree (WTree * tree)
} }
else if (current->sublevel == tree->selected_ptr->sublevel) else if (current->sublevel == tree->selected_ptr->sublevel)
{ {
for (j = strlen (current->name->str) - 1; current->name->str[j] != PATH_SEP; j--); const char *cname;
cname = vfs_path_as_str (current->name);
for (j = strlen (cname) - 1; cname[j] != PATH_SEP; j--)
;
if (vfs_path_equal_len (current->name, tree->selected_ptr->name, j)) if (vfs_path_equal_len (current->name, tree->selected_ptr->name, j))
i++; i++;
} }
@ -355,8 +360,8 @@ show_tree (WTree * tree)
if (current->sublevel == topsublevel) if (current->sublevel == topsublevel)
/* Show full name */ /* Show full name */
tty_print_string (str_fit_to_term tty_print_string (str_fit_to_term
(current->name->str, tree_cols + (tree->is_panel ? 0 : 1), (vfs_path_as_str (current->name),
J_LEFT_FIT)); tree_cols + (tree->is_panel ? 0 : 1), J_LEFT_FIT));
else else
{ {
/* Sub level directory */ /* Sub level directory */
@ -403,8 +408,10 @@ show_tree (WTree * tree)
} }
else if (current->sublevel == tree->selected_ptr->sublevel) else if (current->sublevel == tree->selected_ptr->sublevel)
{ {
for (j = strlen (current->name->str) - 1; current->name->str[j] != PATH_SEP; const char *cname;
j--)
cname = vfs_path_as_str (current->name);
for (j = strlen (cname) - 1; cname[j] != PATH_SEP; j--)
; ;
if (vfs_path_equal_len (current->name, tree->selected_ptr->name, j)) if (vfs_path_equal_len (current->name, tree->selected_ptr->name, j))
break; break;
@ -762,7 +769,7 @@ tree_copy (WTree * tree, const char *default_dest)
return; return;
g_snprintf (msg, sizeof (msg), _("Copy \"%s\" directory to:"), g_snprintf (msg, sizeof (msg), _("Copy \"%s\" directory to:"),
str_trunc (tree->selected_ptr->name->str, 50)); str_trunc (vfs_path_as_str (tree->selected_ptr->name), 50));
dest = input_expand_dialog (Q_ ("DialogTitle|Copy"), dest = input_expand_dialog (Q_ ("DialogTitle|Copy"),
msg, MC_HISTORY_FM_TREE_COPY, default_dest, msg, MC_HISTORY_FM_TREE_COPY, default_dest,
INPUT_COMPLETE_FILENAMES | INPUT_COMPLETE_CD); INPUT_COMPLETE_FILENAMES | INPUT_COMPLETE_CD);
@ -776,7 +783,8 @@ tree_copy (WTree * tree, const char *default_dest)
tctx = file_op_total_context_new (); tctx = file_op_total_context_new ();
file_op_context_create_ui (ctx, FALSE, FILEGUI_DIALOG_MULTI_ITEM); file_op_context_create_ui (ctx, FALSE, FILEGUI_DIALOG_MULTI_ITEM);
tctx->ask_overwrite = FALSE; tctx->ask_overwrite = FALSE;
copy_dir_dir (tctx, ctx, tree->selected_ptr->name->str, dest, TRUE, FALSE, FALSE, NULL); copy_dir_dir (tctx, ctx, vfs_path_as_str (tree->selected_ptr->name), dest, TRUE, FALSE,
FALSE, NULL);
file_op_total_context_destroy (tctx); file_op_total_context_destroy (tctx);
file_op_context_destroy (ctx); file_op_context_destroy (ctx);
} }
@ -799,7 +807,7 @@ tree_move (WTree * tree, const char *default_dest)
return; return;
g_snprintf (msg, sizeof (msg), _("Move \"%s\" directory to:"), g_snprintf (msg, sizeof (msg), _("Move \"%s\" directory to:"),
str_trunc (tree->selected_ptr->name->str, 50)); str_trunc (vfs_path_as_str (tree->selected_ptr->name), 50));
dest = dest =
input_expand_dialog (Q_ ("DialogTitle|Move"), msg, MC_HISTORY_FM_TREE_MOVE, default_dest, input_expand_dialog (Q_ ("DialogTitle|Move"), msg, MC_HISTORY_FM_TREE_MOVE, default_dest,
INPUT_COMPLETE_FILENAMES | INPUT_COMPLETE_CD); INPUT_COMPLETE_FILENAMES | INPUT_COMPLETE_CD);
@ -823,7 +831,7 @@ tree_move (WTree * tree, const char *default_dest)
ctx = file_op_context_new (OP_MOVE); ctx = file_op_context_new (OP_MOVE);
tctx = file_op_total_context_new (); tctx = file_op_total_context_new ();
file_op_context_create_ui (ctx, FALSE, FILEGUI_DIALOG_ONE_ITEM); file_op_context_create_ui (ctx, FALSE, FILEGUI_DIALOG_ONE_ITEM);
move_dir_dir (tctx, ctx, tree->selected_ptr->name->str, dest); move_dir_dir (tctx, ctx, vfs_path_as_str (tree->selected_ptr->name), dest);
file_op_total_context_destroy (tctx); file_op_total_context_destroy (tctx);
file_op_context_destroy (ctx); file_op_context_destroy (ctx);
@ -868,7 +876,7 @@ tree_rmdir (void *data)
char *buf; char *buf;
int result; int result;
buf = g_strdup_printf (_("Delete %s?"), tree->selected_ptr->name->str); buf = g_strdup_printf (_("Delete %s?"), vfs_path_as_str (tree->selected_ptr->name));
result = query_dialog (Q_ ("DialogTitle|Delete"), buf, D_ERROR, 2, _("&Yes"), _("&No")); result = query_dialog (Q_ ("DialogTitle|Delete"), buf, D_ERROR, 2, _("&Yes"), _("&No"));
g_free (buf); g_free (buf);

View File

@ -715,10 +715,13 @@ tree_store_remove_entry (const vfs_path_t * name_vpath)
while (current != NULL && vfs_path_equal_len (current->name, base->name, len)) while (current != NULL && vfs_path_equal_len (current->name, base->name, len))
{ {
gboolean ok; gboolean ok;
const char *cname;
ok = (current->name->str[len] == '\0' || current->name->str[len] == PATH_SEP); cname = vfs_path_as_str (current->name);
ok = (cname[len] == '\0' || cname[len] == PATH_SEP);
if (!ok) if (!ok)
break; break;
old = current; old = current;
current = current->next; current = current->next;
remove_entry (old); remove_entry (old);
@ -736,6 +739,8 @@ tree_store_mark_checked (const char *subname)
vfs_path_t *name; vfs_path_t *name;
tree_entry *current, *base; tree_entry *current, *base;
int flag = 1; int flag = 1;
const char *cname;
if (!ts.loaded) if (!ts.loaded)
return; return;
@ -746,7 +751,8 @@ tree_store_mark_checked (const char *subname)
if (subname[0] == '.' && (subname[1] == 0 || (subname[1] == '.' && subname[2] == 0))) if (subname[0] == '.' && (subname[1] == 0 || (subname[1] == '.' && subname[2] == 0)))
return; return;
if (ts.check_name->str[0] == PATH_SEP && ts.check_name->str[1] == 0) cname = vfs_path_as_str (ts.check_name);
if (cname[0] == PATH_SEP && cname[1] == '\0')
name = vfs_path_build_filename (PATH_SEP_STR, subname, NULL); name = vfs_path_build_filename (PATH_SEP_STR, subname, NULL);
else else
name = vfs_path_append_new (ts.check_name, subname, NULL); name = vfs_path_append_new (ts.check_name, subname, NULL);
@ -777,10 +783,11 @@ tree_store_mark_checked (const char *subname)
{ {
gboolean ok; gboolean ok;
ok = (current->name->str[len] == '\0' || current->name->str[len] == PATH_SEP cname = vfs_path_as_str (current->name);
|| len == 1); ok = (cname[len] == '\0' || cname[len] == PATH_SEP || len == 1);
if (!ok) if (!ok)
break; break;
current->mark = 0; current->mark = 0;
current = current->next; current = current->next;
} }
@ -832,10 +839,13 @@ tree_store_start_check (const vfs_path_t * vpath)
while (current != NULL && vfs_path_equal_len (current->name, ts.check_name, len)) while (current != NULL && vfs_path_equal_len (current->name, ts.check_name, len))
{ {
gboolean ok; gboolean ok;
const char *cname;
ok = (current->name->str[len] == '\0' || current->name->str[len] == PATH_SEP || len == 1); cname = vfs_path_as_str (current->name);
ok = (cname[len] == '\0' || cname[len] == PATH_SEP || len == 1);
if (!ok) if (!ok)
break; break;
current->mark = 1; current->mark = 1;
current = current->next; current = current->next;
} }
@ -865,11 +875,13 @@ tree_store_end_check (void)
while (current != NULL && vfs_path_equal_len (current->name, ts.check_name, len)) while (current != NULL && vfs_path_equal_len (current->name, ts.check_name, len))
{ {
gboolean ok; gboolean ok;
const char *cname;
ok = (current->name->str[len] == '\0' || current->name->str[len] == PATH_SEP || len == 1); cname = vfs_path_as_str (current->name);
ok = (cname[len] == '\0' || cname[len] == PATH_SEP || len == 1);
if (!ok) if (!ok)
break; break;
old = current; old = current;
current = current->next; current = current->next;
if (old->mark) if (old->mark)