mirror of
https://github.com/MidnightCommander/mc
synced 2025-04-01 04:33:24 +03:00
(file_entry_t): use GString instead of fname & fnamelen.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
536fb676d8
commit
6f859e52d0
@ -239,7 +239,7 @@ mc_fhl_get_color_regexp (mc_fhl_filter_t * mc_filter, mc_fhl_t * fhl, file_entry
|
||||
if (mc_filter->search_condition == NULL)
|
||||
return -1;
|
||||
|
||||
if (mc_search_run (mc_filter->search_condition, fe->fname, 0, strlen (fe->fname), NULL))
|
||||
if (mc_search_run (mc_filter->search_condition, fe->fname->str, 0, fe->fname->len, NULL))
|
||||
return mc_filter->color_pair_index;
|
||||
|
||||
return -1;
|
||||
|
@ -118,8 +118,7 @@ typedef struct
|
||||
typedef struct
|
||||
{
|
||||
/* File attributes */
|
||||
size_t fnamelen;
|
||||
char *fname;
|
||||
GString *fname;
|
||||
struct stat st;
|
||||
/* key used for comparing names */
|
||||
char *sort_key;
|
||||
|
@ -3533,22 +3533,24 @@ dview_diff_cmd (const void *f0, const void *f1)
|
||||
const WPanel *panel1 = (const WPanel *) f1;
|
||||
|
||||
file0 =
|
||||
vfs_path_append_new (panel0->cwd_vpath, selection (panel0)->fname, (char *) NULL);
|
||||
vfs_path_append_new (panel0->cwd_vpath, selection (panel0)->fname->str,
|
||||
(char *) NULL);
|
||||
is_dir0 = S_ISDIR (selection (panel0)->st.st_mode);
|
||||
if (is_dir0)
|
||||
{
|
||||
message (D_ERROR, MSG_ERROR, _("\"%s\" is a directory"),
|
||||
path_trunc (selection (panel0)->fname, 30));
|
||||
path_trunc (selection (panel0)->fname->str, 30));
|
||||
goto ret;
|
||||
}
|
||||
|
||||
file1 =
|
||||
vfs_path_append_new (panel1->cwd_vpath, selection (panel1)->fname, (char *) NULL);
|
||||
vfs_path_append_new (panel1->cwd_vpath, selection (panel1)->fname->str,
|
||||
(char *) NULL);
|
||||
is_dir1 = S_ISDIR (selection (panel1)->st.st_mode);
|
||||
if (is_dir1)
|
||||
{
|
||||
message (D_ERROR, MSG_ERROR, _("\"%s\" is a directory"),
|
||||
path_trunc (selection (panel1)->fname, 30));
|
||||
path_trunc (selection (panel1)->fname->str, 30));
|
||||
goto ret;
|
||||
}
|
||||
break;
|
||||
|
@ -829,7 +829,7 @@ advanced_chown_done (gboolean need_update)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static const char *
|
||||
static const GString *
|
||||
next_file (const WPanel * panel)
|
||||
{
|
||||
while (!panel->dir.list[current_file].f.marked)
|
||||
@ -951,10 +951,10 @@ apply_advanced_chowns (WPanel * panel, vfs_path_t * vpath, struct stat *sf)
|
||||
|
||||
do
|
||||
{
|
||||
const char *fname;
|
||||
const GString *fname;
|
||||
|
||||
fname = next_file (panel);
|
||||
vpath = vfs_path_from_str (fname);
|
||||
vpath = vfs_path_from_str (fname->str);
|
||||
ok = (mc_stat (vpath, sf) == 0);
|
||||
|
||||
if (!ok)
|
||||
@ -1004,7 +1004,7 @@ advanced_chown_cmd (WPanel * panel)
|
||||
{ /* do while any files remaining */
|
||||
vfs_path_t *vpath;
|
||||
WDialog *ch_dlg;
|
||||
const char *fname;
|
||||
const GString *fname;
|
||||
int result;
|
||||
int file_idx;
|
||||
|
||||
@ -1018,7 +1018,7 @@ advanced_chown_cmd (WPanel * panel)
|
||||
else
|
||||
fname = selection (panel)->fname; /* single file */
|
||||
|
||||
vpath = vfs_path_from_str (fname);
|
||||
vpath = vfs_path_from_str (fname->str);
|
||||
|
||||
if (mc_stat (vpath, &sf_stat) != 0)
|
||||
{
|
||||
@ -1032,7 +1032,7 @@ advanced_chown_cmd (WPanel * panel)
|
||||
|
||||
file_idx = files_on_begin == 1 ? 1 : (files_on_begin - panel->marked + 1);
|
||||
label_set_textv (l_filename, "%s (%d/%d)",
|
||||
str_fit_to_term (fname, WIDGET (ch_dlg)->cols - 20, J_LEFT_FIT),
|
||||
str_fit_to_term (fname->str, WIDGET (ch_dlg)->cols - 20, J_LEFT_FIT),
|
||||
file_idx, files_on_begin);
|
||||
update_ownership ();
|
||||
|
||||
@ -1050,12 +1050,12 @@ advanced_chown_cmd (WPanel * panel)
|
||||
/* single or last file */
|
||||
if (mc_chmod (vpath, get_mode ()) == -1)
|
||||
message (D_ERROR, MSG_ERROR, _("Cannot chmod \"%s\"\n%s"),
|
||||
fname, unix_error_string (errno));
|
||||
fname->str, unix_error_string (errno));
|
||||
/* call mc_chown only, if mc_chmod didn't fail */
|
||||
else if (mc_chown
|
||||
(vpath, (ch_flags[9] == '+') ? sf_stat.st_uid : (uid_t) (-1),
|
||||
(ch_flags[10] == '+') ? sf_stat.st_gid : (gid_t) (-1)) == -1)
|
||||
message (D_ERROR, MSG_ERROR, _("Cannot chown \"%s\"\n%s"), fname,
|
||||
message (D_ERROR, MSG_ERROR, _("Cannot chown \"%s\"\n%s"), fname->str,
|
||||
unix_error_string (errno));
|
||||
|
||||
end_chown = TRUE;
|
||||
|
@ -1076,7 +1076,7 @@ chattr_done (gboolean need_update)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static const char *
|
||||
static const GString *
|
||||
next_file (const WPanel * panel)
|
||||
{
|
||||
while (!panel->dir.list[current_file].f.marked)
|
||||
@ -1158,10 +1158,10 @@ chattr_apply_mask (WPanel * panel, vfs_path_t * vpath, unsigned long m)
|
||||
|
||||
do
|
||||
{
|
||||
const char *fname;
|
||||
const GString *fname;
|
||||
|
||||
fname = next_file (panel);
|
||||
ok = (fgetflags (fname, &m) == 0);
|
||||
ok = (fgetflags (fname->str, &m) == 0);
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
@ -1174,7 +1174,7 @@ chattr_apply_mask (WPanel * panel, vfs_path_t * vpath, unsigned long m)
|
||||
}
|
||||
else
|
||||
{
|
||||
vpath = vfs_path_from_str (fname);
|
||||
vpath = vfs_path_from_str (fname->str);
|
||||
flags = m;
|
||||
ok = do_chattr (panel, vpath, m);
|
||||
vfs_path_free (vpath, TRUE);
|
||||
@ -1202,7 +1202,8 @@ chattr_cmd (WPanel * panel)
|
||||
{ /* do while any files remaining */
|
||||
vfs_path_t *vpath;
|
||||
WDialog *ch_dlg;
|
||||
const char *fname, *fname2;
|
||||
const GString *fname;
|
||||
const char *fname2;
|
||||
size_t i;
|
||||
int result;
|
||||
|
||||
@ -1223,12 +1224,12 @@ chattr_cmd (WPanel * panel)
|
||||
else
|
||||
fname = selection (panel)->fname; /* single file */
|
||||
|
||||
vpath = vfs_path_from_str (fname);
|
||||
vpath = vfs_path_from_str (fname->str);
|
||||
fname2 = vfs_path_as_str (vpath);
|
||||
|
||||
if (fgetflags (fname2, &flags) != 0)
|
||||
{
|
||||
message (D_ERROR, MSG_ERROR, _("Cannot get flags of \"%s\"\n%s"), fname,
|
||||
message (D_ERROR, MSG_ERROR, _("Cannot get flags of \"%s\"\n%s"), fname->str,
|
||||
unix_error_string (errno));
|
||||
vfs_path_free (vpath, TRUE);
|
||||
break;
|
||||
@ -1236,7 +1237,7 @@ chattr_cmd (WPanel * panel)
|
||||
|
||||
flags_changed = FALSE;
|
||||
|
||||
ch_dlg = chattr_dlg_create (panel, fname, flags);
|
||||
ch_dlg = chattr_dlg_create (panel, fname->str, flags);
|
||||
result = dlg_run (ch_dlg);
|
||||
dlg_destroy (ch_dlg);
|
||||
|
||||
@ -1253,7 +1254,7 @@ chattr_cmd (WPanel * panel)
|
||||
{
|
||||
/* single or last file */
|
||||
if (fsetflags (fname2, flags) == -1 && !ignore_all)
|
||||
message (D_ERROR, MSG_ERROR, _("Cannot chattr \"%s\"\n%s"), fname,
|
||||
message (D_ERROR, MSG_ERROR, _("Cannot chattr \"%s\"\n%s"), fname->str,
|
||||
unix_error_string (errno));
|
||||
end_chattr = TRUE;
|
||||
}
|
||||
|
@ -410,7 +410,7 @@ chmod_done (gboolean need_update)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static const char *
|
||||
static const GString *
|
||||
next_file (const WPanel * panel)
|
||||
{
|
||||
while (!panel->dir.list[current_file].f.marked)
|
||||
@ -492,10 +492,10 @@ apply_mask (WPanel * panel, vfs_path_t * vpath, struct stat *sf)
|
||||
|
||||
do
|
||||
{
|
||||
const char *fname;
|
||||
const GString *fname;
|
||||
|
||||
fname = next_file (panel);
|
||||
vpath = vfs_path_from_str (fname);
|
||||
vpath = vfs_path_from_str (fname->str);
|
||||
ok = (mc_stat (vpath, sf) == 0);
|
||||
|
||||
if (!ok)
|
||||
@ -539,7 +539,7 @@ chmod_cmd (WPanel * panel)
|
||||
vfs_path_t *vpath;
|
||||
WDialog *ch_dlg;
|
||||
struct stat sf_stat;
|
||||
const char *fname;
|
||||
const GString *fname;
|
||||
int i, result;
|
||||
|
||||
do_refresh ();
|
||||
@ -552,7 +552,7 @@ chmod_cmd (WPanel * panel)
|
||||
else
|
||||
fname = selection (panel)->fname; /* single file */
|
||||
|
||||
vpath = vfs_path_from_str (fname);
|
||||
vpath = vfs_path_from_str (fname->str);
|
||||
|
||||
if (mc_stat (vpath, &sf_stat) != 0)
|
||||
{
|
||||
@ -562,7 +562,7 @@ chmod_cmd (WPanel * panel)
|
||||
|
||||
ch_mode = sf_stat.st_mode;
|
||||
|
||||
ch_dlg = chmod_dlg_create (panel, fname, &sf_stat);
|
||||
ch_dlg = chmod_dlg_create (panel, fname->str, &sf_stat);
|
||||
result = dlg_run (ch_dlg);
|
||||
|
||||
switch (result)
|
||||
@ -578,7 +578,7 @@ chmod_cmd (WPanel * panel)
|
||||
{
|
||||
/* single or last file */
|
||||
if (mc_chmod (vpath, ch_mode) == -1 && !ignore_all)
|
||||
message (D_ERROR, MSG_ERROR, _("Cannot chmod \"%s\"\n%s"), fname,
|
||||
message (D_ERROR, MSG_ERROR, _("Cannot chmod \"%s\"\n%s"), fname->str,
|
||||
unix_error_string (errno));
|
||||
end_chmod = TRUE;
|
||||
}
|
||||
|
@ -283,7 +283,7 @@ chown_done (gboolean need_update)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static const char *
|
||||
static const GString *
|
||||
next_file (const WPanel * panel)
|
||||
{
|
||||
while (!panel->dir.list[current_file].f.marked)
|
||||
@ -362,11 +362,11 @@ apply_chowns (WPanel * panel, vfs_path_t * vpath, uid_t u, gid_t g)
|
||||
|
||||
do
|
||||
{
|
||||
const char *fname;
|
||||
const GString *fname;
|
||||
struct stat sf;
|
||||
|
||||
fname = next_file (panel);
|
||||
vpath = vfs_path_from_str (fname);
|
||||
vpath = vfs_path_from_str (fname->str);
|
||||
ok = (mc_stat (vpath, &sf) == 0);
|
||||
|
||||
if (!ok)
|
||||
@ -406,7 +406,7 @@ chown_cmd (WPanel * panel)
|
||||
vfs_path_t *vpath;
|
||||
WDialog *ch_dlg;
|
||||
struct stat sf_stat;
|
||||
const char *fname;
|
||||
const GString *fname;
|
||||
int result;
|
||||
char buffer[BUF_TINY];
|
||||
uid_t new_user = (uid_t) (-1);
|
||||
@ -422,7 +422,7 @@ chown_cmd (WPanel * panel)
|
||||
else
|
||||
fname = selection (panel)->fname; /* single file */
|
||||
|
||||
vpath = vfs_path_from_str (fname);
|
||||
vpath = vfs_path_from_str (fname->str);
|
||||
|
||||
if (mc_stat (vpath, &sf_stat) != 0)
|
||||
{
|
||||
@ -436,7 +436,7 @@ chown_cmd (WPanel * panel)
|
||||
listbox_select_entry (l_user, listbox_search_text (l_user, get_owner (sf_stat.st_uid)));
|
||||
listbox_select_entry (l_group, listbox_search_text (l_group, get_group (sf_stat.st_gid)));
|
||||
|
||||
chown_label (0, str_trunc (fname, GW - 4));
|
||||
chown_label (0, str_trunc (fname->str, GW - 4));
|
||||
chown_label (1, str_trunc (get_owner (sf_stat.st_uid), GW - 4));
|
||||
chown_label (2, str_trunc (get_group (sf_stat.st_gid), GW - 4));
|
||||
size_trunc_len (buffer, GW - 4, sf_stat.st_size, 0, panels_options.kilobyte_si);
|
||||
@ -473,7 +473,7 @@ chown_cmd (WPanel * panel)
|
||||
/* single or last file */
|
||||
if (mc_chown (vpath, new_user, new_group) == -1)
|
||||
message (D_ERROR, MSG_ERROR, _("Cannot chown \"%s\"\n%s"),
|
||||
fname, unix_error_string (errno));
|
||||
fname->str, unix_error_string (errno));
|
||||
end_chown = TRUE;
|
||||
}
|
||||
else if (!try_chown (vpath, new_user, new_group))
|
||||
|
@ -140,7 +140,7 @@ do_view_cmd (WPanel * panel, gboolean plain_view)
|
||||
_("&Yes"), _("&No")) != 0)
|
||||
return;
|
||||
|
||||
fname_vpath = vfs_path_from_str (selection (panel)->fname);
|
||||
fname_vpath = vfs_path_from_str (selection (panel)->fname->str);
|
||||
if (!panel_cd (panel, fname_vpath, cd_exact))
|
||||
message (D_ERROR, MSG_ERROR, _("Cannot change directory"));
|
||||
vfs_path_free (fname_vpath, TRUE);
|
||||
@ -151,7 +151,7 @@ do_view_cmd (WPanel * panel, gboolean plain_view)
|
||||
vfs_path_t *filename_vpath;
|
||||
|
||||
file_idx = panel->selected;
|
||||
filename_vpath = vfs_path_from_str (panel->dir.list[file_idx].fname);
|
||||
filename_vpath = vfs_path_from_str (panel->dir.list[file_idx].fname->str);
|
||||
view_file (filename_vpath, plain_view, use_internal_view);
|
||||
vfs_path_free (filename_vpath, TRUE);
|
||||
}
|
||||
@ -289,7 +289,7 @@ compare_dir (WPanel * panel, WPanel * other, enum CompareMode mode)
|
||||
|
||||
/* Search the corresponding entry from the other panel */
|
||||
for (j = 0; j < other->dir.len; j++)
|
||||
if (strcmp (source->fname, other->dir.list[j].fname) == 0)
|
||||
if (g_string_equal (source->fname, other->dir.list[j].fname))
|
||||
break;
|
||||
|
||||
if (j >= other->dir.len)
|
||||
@ -329,8 +329,10 @@ compare_dir (WPanel * panel, WPanel * other, enum CompareMode mode)
|
||||
{
|
||||
vfs_path_t *src_name, *dst_name;
|
||||
|
||||
src_name = vfs_path_append_new (panel->cwd_vpath, source->fname, (char *) NULL);
|
||||
dst_name = vfs_path_append_new (other->cwd_vpath, target->fname, (char *) NULL);
|
||||
src_name =
|
||||
vfs_path_append_new (panel->cwd_vpath, source->fname->str, (char *) NULL);
|
||||
dst_name =
|
||||
vfs_path_append_new (other->cwd_vpath, target->fname->str, (char *) NULL);
|
||||
if (compare_files (src_name, dst_name, source->st.st_size))
|
||||
do_file_mark (panel, i, 1);
|
||||
vfs_path_free (src_name, TRUE);
|
||||
@ -626,7 +628,7 @@ view_file_cmd (const WPanel * panel)
|
||||
|
||||
filename =
|
||||
input_expand_dialog (_("View file"), _("Filename:"),
|
||||
MC_HISTORY_FM_VIEW_FILE, selection (panel)->fname,
|
||||
MC_HISTORY_FM_VIEW_FILE, selection (panel)->fname->str,
|
||||
INPUT_COMPLETE_FILENAMES);
|
||||
if (filename == NULL)
|
||||
return;
|
||||
@ -654,7 +656,7 @@ view_filtered_cmd (const WPanel * panel)
|
||||
const char *initial_command;
|
||||
|
||||
if (input_is_empty (cmdline))
|
||||
initial_command = selection (panel)->fname;
|
||||
initial_command = selection (panel)->fname->str;
|
||||
else
|
||||
initial_command = cmdline->buffer;
|
||||
|
||||
@ -716,7 +718,7 @@ edit_cmd (const WPanel * panel)
|
||||
{
|
||||
vfs_path_t *fname;
|
||||
|
||||
fname = vfs_path_from_str (selection (panel)->fname);
|
||||
fname = vfs_path_from_str (selection (panel)->fname->str);
|
||||
if (regex_command (fname, "Edit") == 0)
|
||||
do_edit (fname);
|
||||
vfs_path_free (fname, TRUE);
|
||||
@ -730,7 +732,7 @@ edit_cmd_force_internal (const WPanel * panel)
|
||||
{
|
||||
vfs_path_t *fname;
|
||||
|
||||
fname = vfs_path_from_str (selection (panel)->fname);
|
||||
fname = vfs_path_from_str (selection (panel)->fname->str);
|
||||
if (regex_command (fname, "Edit") == 0)
|
||||
edit_file_at_line (fname, TRUE, 1);
|
||||
vfs_path_free (fname, TRUE);
|
||||
@ -836,8 +838,8 @@ mkdir_cmd (WPanel * panel)
|
||||
const char *name = "";
|
||||
|
||||
/* If 'on' then automatically fills name with current selected item name */
|
||||
if (auto_fill_mkdir_name && !DIR_IS_DOTDOT (selection (panel)->fname))
|
||||
name = selection (panel)->fname;
|
||||
if (auto_fill_mkdir_name && !DIR_IS_DOTDOT (selection (panel)->fname->str))
|
||||
name = selection (panel)->fname->str;
|
||||
|
||||
dir =
|
||||
input_expand_dialog (_("Create a new Directory"),
|
||||
@ -1197,7 +1199,7 @@ swap_cmd (void)
|
||||
void
|
||||
link_cmd (link_type_t link_type)
|
||||
{
|
||||
char *filename = selection (current_panel)->fname;
|
||||
const char *filename = selection (current_panel)->fname->str;
|
||||
|
||||
if (filename != NULL)
|
||||
do_link (link_type, filename);
|
||||
@ -1212,7 +1214,7 @@ edit_symlink_cmd (void)
|
||||
const char *p;
|
||||
|
||||
fe = selection (current_panel);
|
||||
p = fe->fname;
|
||||
p = fe->fname->str;
|
||||
|
||||
if (!S_ISLNK (fe->st.st_mode))
|
||||
message (D_ERROR, MSG_ERROR, _("'%s' is not a symbolic link"), p);
|
||||
@ -1377,7 +1379,7 @@ smart_dirsize_cmd (WPanel * panel)
|
||||
{
|
||||
const file_entry_t *entry = &panel->dir.list[panel->selected];
|
||||
|
||||
if ((S_ISDIR (entry->st.st_mode) && DIR_IS_DOTDOT (entry->fname)) || panel->dirs_marked)
|
||||
if ((S_ISDIR (entry->st.st_mode) && DIR_IS_DOTDOT (entry->fname->str)) || panel->dirs_marked)
|
||||
dirsizes_cmd (panel);
|
||||
else
|
||||
single_dirsize_cmd (panel);
|
||||
@ -1390,7 +1392,7 @@ single_dirsize_cmd (WPanel * panel)
|
||||
{
|
||||
file_entry_t *entry = &panel->dir.list[panel->selected];
|
||||
|
||||
if (S_ISDIR (entry->st.st_mode) && !DIR_IS_DOTDOT (entry->fname))
|
||||
if (S_ISDIR (entry->st.st_mode) && !DIR_IS_DOTDOT (entry->fname->str))
|
||||
{
|
||||
size_t dir_count = 0;
|
||||
size_t count = 0;
|
||||
@ -1398,7 +1400,7 @@ single_dirsize_cmd (WPanel * panel)
|
||||
dirsize_status_msg_t dsm;
|
||||
vfs_path_t *p;
|
||||
|
||||
p = vfs_path_from_str (entry->fname);
|
||||
p = vfs_path_from_str (entry->fname->str);
|
||||
|
||||
memset (&dsm, 0, sizeof (dsm));
|
||||
status_msg_init (STATUS_MSG (&dsm), _("Directory scanning"), 0, dirsize_status_init_cb,
|
||||
@ -1441,7 +1443,7 @@ dirsizes_cmd (WPanel * panel)
|
||||
for (i = 0; i < panel->dir.len; i++)
|
||||
if (S_ISDIR (panel->dir.list[i].st.st_mode)
|
||||
&& ((panel->dirs_marked != 0 && panel->dir.list[i].f.marked)
|
||||
|| panel->dirs_marked == 0) && !DIR_IS_DOTDOT (panel->dir.list[i].fname))
|
||||
|| panel->dirs_marked == 0) && !DIR_IS_DOTDOT (panel->dir.list[i].fname->str))
|
||||
{
|
||||
vfs_path_t *p;
|
||||
size_t dir_count = 0;
|
||||
@ -1449,7 +1451,7 @@ dirsizes_cmd (WPanel * panel)
|
||||
uintmax_t total = 0;
|
||||
gboolean ok;
|
||||
|
||||
p = vfs_path_from_str (panel->dir.list[i].fname);
|
||||
p = vfs_path_from_str (panel->dir.list[i].fname->str);
|
||||
ok = compute_dir_size (p, &dsm, &dir_count, &count, &total, FALSE) != FILE_CONT;
|
||||
vfs_path_free (p, TRUE);
|
||||
if (ok)
|
||||
|
@ -294,8 +294,7 @@ dir_list_append (dir_list * list, const char *fname, const struct stat * st,
|
||||
return FALSE;
|
||||
|
||||
fentry = &list->list[list->len];
|
||||
fentry->fnamelen = strlen (fname);
|
||||
fentry->fname = g_strndup (fname, fentry->fnamelen);
|
||||
fentry->fname = g_string_new (fname);
|
||||
fentry->f.marked = 0;
|
||||
fentry->f.link_to_dir = link_to_dir ? 1 : 0;
|
||||
fentry->f.stale_link = stale_link ? 1 : 0;
|
||||
@ -332,9 +331,9 @@ sort_name (file_entry_t * a, file_entry_t * b)
|
||||
{
|
||||
/* create key if does not exist, key will be freed after sorting */
|
||||
if (a->sort_key == NULL)
|
||||
a->sort_key = str_create_key_for_filename (a->fname, case_sensitive);
|
||||
a->sort_key = str_create_key_for_filename (a->fname->str, case_sensitive);
|
||||
if (b->sort_key == NULL)
|
||||
b->sort_key = str_create_key_for_filename (b->fname, case_sensitive);
|
||||
b->sort_key = str_create_key_for_filename (b->fname->str, case_sensitive);
|
||||
|
||||
return key_collate (a->sort_key, b->sort_key);
|
||||
}
|
||||
@ -351,7 +350,7 @@ sort_vers (file_entry_t * a, file_entry_t * b)
|
||||
int bd = MY_ISDIR (b);
|
||||
|
||||
if (ad == bd || panels_options.mix_all_files)
|
||||
return filevercmp (a->fname, b->fname) * reverse;
|
||||
return filevercmp (a->fname->str, b->fname->str) * reverse;
|
||||
|
||||
return bd - ad;
|
||||
}
|
||||
@ -369,9 +368,9 @@ sort_ext (file_entry_t * a, file_entry_t * b)
|
||||
int r;
|
||||
|
||||
if (a->second_sort_key == NULL)
|
||||
a->second_sort_key = str_create_key (extension (a->fname), case_sensitive);
|
||||
a->second_sort_key = str_create_key (extension (a->fname->str), case_sensitive);
|
||||
if (b->second_sort_key == NULL)
|
||||
b->second_sort_key = str_create_key (extension (b->fname), case_sensitive);
|
||||
b->second_sort_key = str_create_key (extension (b->fname->str), case_sensitive);
|
||||
|
||||
r = str_key_collate (a->second_sort_key, b->second_sort_key, case_sensitive);
|
||||
if (r != 0)
|
||||
@ -493,7 +492,7 @@ dir_list_sort (dir_list * list, GCompareFunc sort, const dir_sort_options_t * so
|
||||
|
||||
/* If there is an ".." entry the caller must take care to
|
||||
ensure that it occupies the first list element. */
|
||||
dot_dot_found = DIR_IS_DOTDOT (fentry->fname) ? 1 : 0;
|
||||
dot_dot_found = DIR_IS_DOTDOT (fentry->fname->str) ? 1 : 0;
|
||||
reverse = sort_op->reverse ? -1 : 1;
|
||||
case_sensitive = sort_op->case_sensitive ? 1 : 0;
|
||||
exec_first = sort_op->exec_first;
|
||||
@ -516,7 +515,8 @@ dir_list_clean (dir_list * list)
|
||||
file_entry_t *fentry;
|
||||
|
||||
fentry = &list->list[i];
|
||||
MC_PTR_FREE (fentry->fname);
|
||||
g_string_free (fentry->fname, TRUE);
|
||||
fentry->fname = NULL;
|
||||
}
|
||||
|
||||
list->len = 0;
|
||||
@ -536,7 +536,7 @@ dir_list_free_list (dir_list * list)
|
||||
file_entry_t *fentry;
|
||||
|
||||
fentry = &list->list[i];
|
||||
g_free (fentry->fname);
|
||||
g_string_free (fentry->fname, TRUE);
|
||||
}
|
||||
|
||||
MC_PTR_FREE (list->list);
|
||||
@ -561,8 +561,7 @@ dir_list_init (dir_list * list)
|
||||
|
||||
fentry = &list->list[0];
|
||||
memset (fentry, 0, sizeof (*fentry));
|
||||
fentry->fnamelen = 2;
|
||||
fentry->fname = g_strndup ("..", fentry->fnamelen);
|
||||
fentry->fname = g_string_new ("..");
|
||||
fentry->f.link_to_dir = 0;
|
||||
fentry->f.stale_link = 0;
|
||||
fentry->f.dir_size_computed = 0;
|
||||
@ -726,8 +725,7 @@ dir_list_reload (dir_list * list, const vfs_path_t * vpath, GCompareFunc sort,
|
||||
fentry = &list->list[i];
|
||||
dfentry = &dir_copy.list[i];
|
||||
|
||||
dfentry->fnamelen = fentry->fnamelen;
|
||||
dfentry->fname = g_strndup (fentry->fname, fentry->fnamelen);
|
||||
dfentry->fname = g_string_new_len (fentry->fname->str, fentry->fname->len);
|
||||
dfentry->f.marked = fentry->f.marked;
|
||||
dfentry->f.dir_size_computed = fentry->f.dir_size_computed;
|
||||
dfentry->f.link_to_dir = fentry->f.link_to_dir;
|
||||
@ -736,7 +734,7 @@ dir_list_reload (dir_list * list, const vfs_path_t * vpath, GCompareFunc sort,
|
||||
dfentry->second_sort_key = NULL;
|
||||
if (fentry->f.marked)
|
||||
{
|
||||
g_hash_table_insert (marked_files, dfentry->fname, dfentry);
|
||||
g_hash_table_insert (marked_files, dfentry->fname->str, dfentry);
|
||||
marked_cnt++;
|
||||
}
|
||||
}
|
||||
|
@ -706,7 +706,7 @@ panel_compute_totals (const WPanel * panel, dirsize_status_msg_t * sm, size_t *
|
||||
vfs_path_t *p;
|
||||
FileProgressStatus status;
|
||||
|
||||
p = vfs_path_append_new (panel->cwd_vpath, fe->fname, (char *) NULL);
|
||||
p = vfs_path_append_new (panel->cwd_vpath, fe->fname->str, (char *) NULL);
|
||||
status = do_compute_dir_size (p, sm, &dir_count, ret_count, ret_total, stat_func);
|
||||
vfs_path_free (p, TRUE);
|
||||
|
||||
@ -1727,10 +1727,10 @@ panel_get_file (const WPanel * panel)
|
||||
|
||||
for (i = 0; i < panel->dir.len; i++)
|
||||
if (panel->dir.list[i].f.marked)
|
||||
return panel->dir.list[i].fname;
|
||||
return panel->dir.list[i].fname->str;
|
||||
}
|
||||
|
||||
return panel->dir.list[panel->selected].fname;
|
||||
return panel->dir.list[panel->selected].fname->str;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -1742,7 +1742,7 @@ check_single_entry (const WPanel * panel, gboolean force_single, struct stat *sr
|
||||
gboolean ok;
|
||||
|
||||
if (force_single)
|
||||
source = selection (panel)->fname;
|
||||
source = selection (panel)->fname->str;
|
||||
else
|
||||
source = panel_get_file (panel);
|
||||
|
||||
@ -3366,7 +3366,7 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl
|
||||
if (!panel->dir.list[i].f.marked)
|
||||
continue; /* Skip the unmarked ones */
|
||||
|
||||
source2 = panel->dir.list[i].fname;
|
||||
source2 = panel->dir.list[i].fname->str;
|
||||
src_stat = panel->dir.list[i].st;
|
||||
|
||||
value = operate_one_file (panel, operation, tctx, ctx, source2, &src_stat, dest);
|
||||
|
@ -148,7 +148,7 @@ treebox_cmd (void)
|
||||
{
|
||||
char *sel_dir;
|
||||
|
||||
sel_dir = tree_box (selection (current_panel)->fname);
|
||||
sel_dir = tree_box (selection (current_panel)->fname->str);
|
||||
if (sel_dir != NULL)
|
||||
{
|
||||
vfs_path_t *sel_vdir;
|
||||
@ -740,7 +740,8 @@ put_link (WPanel * panel)
|
||||
vfs_path_t *vpath;
|
||||
int i;
|
||||
|
||||
vpath = vfs_path_append_new (panel->cwd_vpath, selection (panel)->fname, (char *) NULL);
|
||||
vpath =
|
||||
vfs_path_append_new (panel->cwd_vpath, selection (panel)->fname->str, (char *) NULL);
|
||||
i = mc_readlink (vpath, buffer, sizeof (buffer) - 1);
|
||||
vfs_path_free (vpath, TRUE);
|
||||
|
||||
@ -790,7 +791,7 @@ put_current_selected (void)
|
||||
tmp = vfs_path_as_str (selected_name);
|
||||
}
|
||||
else
|
||||
tmp = selection (current_panel)->fname;
|
||||
tmp = selection (current_panel)->fname->str;
|
||||
|
||||
command_insert (cmdline, tmp, TRUE);
|
||||
}
|
||||
@ -810,12 +811,12 @@ put_tagged (WPanel * panel)
|
||||
for (i = 0; i < panel->dir.len; i++)
|
||||
{
|
||||
if (panel->dir.list[i].f.marked)
|
||||
command_insert (cmdline, panel->dir.list[i].fname, TRUE);
|
||||
command_insert (cmdline, panel->dir.list[i].fname->str, TRUE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
command_insert (cmdline, panel->dir.list[panel->selected].fname, TRUE);
|
||||
command_insert (cmdline, panel->dir.list[panel->selected].fname->str, TRUE);
|
||||
}
|
||||
input_enable_update (cmdline);
|
||||
}
|
||||
|
@ -1851,14 +1851,14 @@ do_find (WPanel * panel, const char *start_dir, ssize_t start_dir_len, const cha
|
||||
|
||||
/* don't add files more than once to the panel */
|
||||
if (!content_is_empty && list->len != 0
|
||||
&& strcmp (list->list[list->len - 1].fname, p) == 0)
|
||||
&& strcmp (list->list[list->len - 1].fname->str, p) == 0)
|
||||
{
|
||||
g_free (name);
|
||||
continue;
|
||||
}
|
||||
|
||||
list->list[list->len].fnamelen = strlen (p);
|
||||
list->list[list->len].fname = g_strndup (p, list->list[list->len].fnamelen);
|
||||
list->list[list->len].fname = g_string_new_len (list->list[list->len].fname->str,
|
||||
list->list[list->len].fname->len);
|
||||
list->list[list->len].f.marked = 0;
|
||||
list->list[list->len].f.link_to_dir = link_to_dir ? 1 : 0;
|
||||
list->list[list->len].f.stale_link = stale_link ? 1 : 0;
|
||||
|
@ -270,7 +270,7 @@ info_show_info (WInfo * info)
|
||||
vfs_path_t *vpath;
|
||||
unsigned long attr;
|
||||
|
||||
vpath = vfs_path_from_str (current_panel->dir.list[current_panel->selected].fname);
|
||||
vpath = vfs_path_from_str (current_panel->dir.list[current_panel->selected].fname->str);
|
||||
|
||||
if (fgetflags (vfs_path_as_str (vpath), &attr) == 0)
|
||||
tty_printf (_("Attributes: %s"), chattr_get_as_str (attr));
|
||||
@ -297,7 +297,7 @@ info_show_info (WInfo * info)
|
||||
const char *fname;
|
||||
|
||||
widget_gotoyx (w, 3, 2);
|
||||
fname = current_panel->dir.list[current_panel->selected].fname;
|
||||
fname = current_panel->dir.list[current_panel->selected].fname->str;
|
||||
str_printf (buff, file_label, str_trunc (fname, w->cols - i18n_adjust));
|
||||
tty_print_string (buff->str);
|
||||
}
|
||||
|
@ -1174,7 +1174,7 @@ create_panel (int num, panel_view_mode_t type)
|
||||
new_widget = WIDGET (mcview_new (y, x, lines, cols, TRUE));
|
||||
the_other_panel = PANEL (panels[the_other].widget);
|
||||
if (the_other_panel != NULL)
|
||||
file_name = the_other_panel->dir.list[the_other_panel->selected].fname;
|
||||
file_name = the_other_panel->dir.list[the_other_panel->selected].fname->str;
|
||||
else
|
||||
file_name = "";
|
||||
|
||||
|
@ -456,7 +456,7 @@ string_file_name (file_entry_t * fe, int len)
|
||||
(void) len;
|
||||
|
||||
g_string_set_size (string_file_name_buffer, 0);
|
||||
g_string_append_len (string_file_name_buffer, fe->fname, fe->fnamelen);
|
||||
g_string_append_len (string_file_name_buffer, fe->fname->str, fe->fname->len);
|
||||
|
||||
return string_file_name_buffer->str;
|
||||
}
|
||||
@ -509,7 +509,7 @@ string_file_size (file_entry_t * fe, int len)
|
||||
static char buffer[BUF_TINY];
|
||||
|
||||
/* Don't ever show size of ".." since we don't calculate it */
|
||||
if (DIR_IS_DOTDOT (fe->fname))
|
||||
if (DIR_IS_DOTDOT (fe->fname->str))
|
||||
return _("UP--DIR");
|
||||
|
||||
#ifdef HAVE_STRUCT_STAT_ST_RDEV
|
||||
@ -531,7 +531,7 @@ string_file_size_brief (file_entry_t * fe, int len)
|
||||
if (S_ISLNK (fe->st.st_mode) && !link_isdir (fe))
|
||||
return _("SYMLINK");
|
||||
|
||||
if ((S_ISDIR (fe->st.st_mode) || link_isdir (fe)) && !DIR_IS_DOTDOT (fe->fname))
|
||||
if ((S_ISDIR (fe->st.st_mode) || link_isdir (fe)) && !DIR_IS_DOTDOT (fe->fname->str))
|
||||
return _("SUB-DIR");
|
||||
|
||||
return string_file_size (fe, len);
|
||||
@ -1010,7 +1010,7 @@ display_mini_info (WPanel * panel)
|
||||
int len;
|
||||
|
||||
lc_link_vpath =
|
||||
vfs_path_append_new (panel->cwd_vpath, panel->dir.list[panel->selected].fname,
|
||||
vfs_path_append_new (panel->cwd_vpath, panel->dir.list[panel->selected].fname->str,
|
||||
(char *) NULL);
|
||||
len = mc_readlink (lc_link_vpath, link_target, MC_MAXPATHLEN - 1);
|
||||
vfs_path_free (lc_link_vpath, TRUE);
|
||||
@ -1023,7 +1023,7 @@ display_mini_info (WPanel * panel)
|
||||
else
|
||||
tty_print_string (str_fit_to_term (_("<readlink failed>"), w->cols - 2, J_LEFT));
|
||||
}
|
||||
else if (DIR_IS_DOTDOT (panel->dir.list[panel->selected].fname))
|
||||
else if (DIR_IS_DOTDOT (panel->dir.list[panel->selected].fname->str))
|
||||
{
|
||||
/* FIXME:
|
||||
* while loading directory (dir_list_load() and dir_list_reload()),
|
||||
@ -2006,7 +2006,7 @@ maybe_cd (WPanel * panel, gboolean move_up_dir)
|
||||
{
|
||||
vfs_path_t *vpath;
|
||||
|
||||
vpath = vfs_path_from_str (selection (panel)->fname);
|
||||
vpath = vfs_path_from_str (selection (panel)->fname->str);
|
||||
panel_cd (panel, vpath, cd_exact);
|
||||
vfs_path_free (vpath, TRUE);
|
||||
return MSG_HANDLED;
|
||||
@ -2045,7 +2045,7 @@ unselect_item (WPanel * panel)
|
||||
static void
|
||||
panel_select_ext_cmd (WPanel * panel)
|
||||
{
|
||||
char *filename;
|
||||
GString *filename;
|
||||
gboolean do_select;
|
||||
char *reg_exp, *cur_file_ext;
|
||||
mc_search_t *search;
|
||||
@ -2057,7 +2057,7 @@ panel_select_ext_cmd (WPanel * panel)
|
||||
|
||||
do_select = !selection (panel)->f.marked;
|
||||
|
||||
cur_file_ext = strutils_regex_escape (extension (filename));
|
||||
cur_file_ext = strutils_regex_escape (extension (filename->str));
|
||||
if (cur_file_ext[0] != '\0')
|
||||
reg_exp = g_strconcat ("^.*\\.", cur_file_ext, "$", (char *) NULL);
|
||||
else
|
||||
@ -2073,10 +2073,10 @@ panel_select_ext_cmd (WPanel * panel)
|
||||
{
|
||||
file_entry_t *file_entry = &panel->dir.list[i];
|
||||
|
||||
if (DIR_IS_DOTDOT (file_entry->fname) || S_ISDIR (file_entry->st.st_mode))
|
||||
if (DIR_IS_DOTDOT (file_entry->fname->str) || S_ISDIR (file_entry->st.st_mode))
|
||||
continue;
|
||||
|
||||
if (!mc_search_run (search, file_entry->fname, 0, file_entry->fnamelen, NULL))
|
||||
if (!mc_search_run (search, file_entry->fname->str, 0, file_entry->fname->len, NULL))
|
||||
continue;
|
||||
|
||||
do_file_mark (panel, i, do_select ? 1 : 0);
|
||||
@ -2268,35 +2268,39 @@ goto_parent_dir (WPanel * panel)
|
||||
cd_up_dir (panel);
|
||||
else
|
||||
{
|
||||
char *fname = panel->dir.list[panel->selected].fname;
|
||||
GString *fname = panel->dir.list[panel->selected].fname;
|
||||
const char *bname;
|
||||
vfs_path_t *dname_vpath;
|
||||
|
||||
if (g_path_is_absolute (fname))
|
||||
fname = g_strdup (fname);
|
||||
if (g_path_is_absolute (fname->str))
|
||||
fname = g_string_new_len (fname->str, fname->len);
|
||||
else
|
||||
fname =
|
||||
mc_build_filename (vfs_path_as_str (panelized_panel.root_vpath), fname,
|
||||
{
|
||||
char *fname2;
|
||||
|
||||
fname2 =
|
||||
mc_build_filename (vfs_path_as_str (panelized_panel.root_vpath), fname->str,
|
||||
(char *) NULL);
|
||||
|
||||
bname = x_basename (fname);
|
||||
fname = g_string_new (fname2);
|
||||
g_free (fname2);
|
||||
}
|
||||
|
||||
if (bname == fname)
|
||||
bname = x_basename (fname->str);
|
||||
|
||||
if (bname == fname->str)
|
||||
dname_vpath = vfs_path_from_str (".");
|
||||
else
|
||||
{
|
||||
char *dname;
|
||||
|
||||
dname = g_strndup (fname, bname - fname);
|
||||
dname_vpath = vfs_path_from_str (dname);
|
||||
g_free (dname);
|
||||
g_string_truncate (fname, bname - fname->str);
|
||||
dname_vpath = vfs_path_from_str (fname->str);
|
||||
}
|
||||
|
||||
panel_cd (panel, dname_vpath, cd_exact);
|
||||
try_to_select (panel, bname);
|
||||
|
||||
vfs_path_free (dname_vpath, TRUE);
|
||||
g_free (fname);
|
||||
g_string_free (fname, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2335,7 +2339,7 @@ goto_child_dir (WPanel * panel)
|
||||
{
|
||||
vfs_path_t *vpath;
|
||||
|
||||
vpath = vfs_path_from_str (selection (panel)->fname);
|
||||
vpath = vfs_path_from_str (selection (panel)->fname->str);
|
||||
panel_cd (panel, vpath, cd_exact);
|
||||
vfs_path_free (vpath, TRUE);
|
||||
}
|
||||
@ -2567,12 +2571,13 @@ panel_select_unselect_files (WPanel * panel, const char *title, const char *hist
|
||||
|
||||
for (i = 0; i < panel->dir.len; i++)
|
||||
{
|
||||
if (DIR_IS_DOTDOT (panel->dir.list[i].fname))
|
||||
if (DIR_IS_DOTDOT (panel->dir.list[i].fname->str))
|
||||
continue;
|
||||
if (S_ISDIR (panel->dir.list[i].st.st_mode) && files_only)
|
||||
continue;
|
||||
|
||||
if (mc_search_run (search, panel->dir.list[i].fname, 0, panel->dir.list[i].fnamelen, NULL))
|
||||
if (mc_search_run
|
||||
(search, panel->dir.list[i].fname->str, 0, panel->dir.list[i].fname->len, NULL))
|
||||
do_file_mark (panel, i, do_select ? 1 : 0);
|
||||
}
|
||||
|
||||
@ -2702,7 +2707,8 @@ do_search (WPanel * panel, int c_code)
|
||||
break;
|
||||
wrapped = TRUE;
|
||||
}
|
||||
if (mc_search_run (search, panel->dir.list[i].fname, 0, panel->dir.list[i].fnamelen, NULL))
|
||||
if (mc_search_run
|
||||
(search, panel->dir.list[i].fname->str, 0, panel->dir.list[i].fname->len, NULL))
|
||||
{
|
||||
sel = i;
|
||||
is_found = TRUE;
|
||||
@ -2781,6 +2787,7 @@ stop_search (WPanel * panel)
|
||||
static gboolean
|
||||
do_enter_on_file_entry (WPanel * panel, file_entry_t * fe)
|
||||
{
|
||||
const char *fname = fe->fname->str;
|
||||
vfs_path_t *full_name_vpath;
|
||||
gboolean ok;
|
||||
|
||||
@ -2792,14 +2799,14 @@ do_enter_on_file_entry (WPanel * panel, file_entry_t * fe)
|
||||
{
|
||||
vfs_path_t *fname_vpath;
|
||||
|
||||
fname_vpath = vfs_path_from_str (fe->fname);
|
||||
fname_vpath = vfs_path_from_str (fname);
|
||||
if (!panel_cd (panel, fname_vpath, cd_exact))
|
||||
message (D_ERROR, MSG_ERROR, _("Cannot change directory"));
|
||||
vfs_path_free (fname_vpath, TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
full_name_vpath = vfs_path_append_new (panel->cwd_vpath, fe->fname, (char *) NULL);
|
||||
full_name_vpath = vfs_path_append_new (panel->cwd_vpath, fname, (char *) NULL);
|
||||
|
||||
/* Try associated command */
|
||||
ok = regex_command (full_name_vpath, "Open") != 0;
|
||||
@ -2808,7 +2815,7 @@ do_enter_on_file_entry (WPanel * panel, file_entry_t * fe)
|
||||
return TRUE;
|
||||
|
||||
/* Check if the file is executable */
|
||||
full_name_vpath = vfs_path_append_new (panel->cwd_vpath, fe->fname, (char *) NULL);
|
||||
full_name_vpath = vfs_path_append_new (panel->cwd_vpath, fname, (char *) NULL);
|
||||
ok = (is_exe (fe->st.st_mode) && if_link_is_exe (full_name_vpath, fe));
|
||||
vfs_path_free (full_name_vpath, TRUE);
|
||||
if (!ok)
|
||||
@ -2824,7 +2831,7 @@ do_enter_on_file_entry (WPanel * panel, file_entry_t * fe)
|
||||
int ret;
|
||||
vfs_path_t *tmp_vpath;
|
||||
|
||||
tmp_vpath = vfs_path_append_new (vfs_get_raw_current_dir (), fe->fname, (char *) NULL);
|
||||
tmp_vpath = vfs_path_append_new (vfs_get_raw_current_dir (), fname, (char *) NULL);
|
||||
ret = mc_setctl (tmp_vpath, VFS_SETCTL_RUN, NULL);
|
||||
vfs_path_free (tmp_vpath, TRUE);
|
||||
/* We took action only if the dialog was shown or the execution was successful */
|
||||
@ -2834,7 +2841,7 @@ do_enter_on_file_entry (WPanel * panel, file_entry_t * fe)
|
||||
{
|
||||
char *tmp, *cmd;
|
||||
|
||||
tmp = name_quote (fe->fname, FALSE);
|
||||
tmp = name_quote (fname, FALSE);
|
||||
cmd = g_strconcat (".", PATH_SEP_STR, tmp, (char *) NULL);
|
||||
g_free (tmp);
|
||||
shell_execute (cmd, 0);
|
||||
@ -2882,7 +2889,7 @@ chdir_other_panel (WPanel * panel)
|
||||
create_panel (get_other_index (), view_listing);
|
||||
|
||||
if (S_ISDIR (entry->st.st_mode) || link_isdir (entry))
|
||||
new_dir_vpath = vfs_path_append_new (panel->cwd_vpath, entry->fname, (char *) NULL);
|
||||
new_dir_vpath = vfs_path_append_new (panel->cwd_vpath, entry->fname->str, (char *) NULL);
|
||||
else
|
||||
{
|
||||
new_dir_vpath = vfs_path_append_new (panel->cwd_vpath, "..", (char *) NULL);
|
||||
@ -2918,7 +2925,7 @@ panel_sync_other (const WPanel * panel)
|
||||
|
||||
/* try to select current filename on the other panel */
|
||||
if (!panel->is_panelized)
|
||||
try_to_select (other_panel, selection (panel)->fname);
|
||||
try_to_select (other_panel, selection (panel)->fname->str);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -2940,11 +2947,11 @@ chdir_to_readlink (WPanel * panel)
|
||||
if (!S_ISLNK (panel->dir.list[panel->selected].st.st_mode))
|
||||
return;
|
||||
|
||||
i = readlink (selection (panel)->fname, buffer, MC_MAXPATHLEN - 1);
|
||||
i = readlink (selection (panel)->fname->str, buffer, MC_MAXPATHLEN - 1);
|
||||
if (i < 0)
|
||||
return;
|
||||
|
||||
panel_fname_vpath = vfs_path_from_str (selection (panel)->fname);
|
||||
panel_fname_vpath = vfs_path_from_str (selection (panel)->fname->str);
|
||||
ok = (mc_stat (panel_fname_vpath, &st) >= 0);
|
||||
vfs_path_free (panel_fname_vpath, TRUE);
|
||||
if (!ok)
|
||||
@ -3960,9 +3967,9 @@ reload_panelized (WPanel * panel)
|
||||
{
|
||||
vfs_path_t *vpath;
|
||||
|
||||
vpath = vfs_path_from_str (list->list[i].fname);
|
||||
vpath = vfs_path_from_str (list->list[i].fname->str);
|
||||
if (mc_lstat (vpath, &list->list[i].st) != 0)
|
||||
g_free (list->list[i].fname);
|
||||
g_string_free (list->list[i].fname, TRUE);
|
||||
else
|
||||
{
|
||||
if (j != i)
|
||||
@ -4002,7 +4009,8 @@ update_one_panel_widget (WPanel * panel, panel_update_flags_t flags, const char
|
||||
|
||||
if (free_pointer)
|
||||
{
|
||||
my_current_file = g_strdup (panel->dir.list[panel->selected].fname);
|
||||
my_current_file = g_strndup (panel->dir.list[panel->selected].fname->str,
|
||||
panel->dir.list[panel->selected].fname->len);
|
||||
current_file = my_current_file;
|
||||
}
|
||||
|
||||
@ -4075,7 +4083,7 @@ do_try_to_select (WPanel * panel, const char *name)
|
||||
/* Search that subdir or filename without prefix (if not panelized panel), select it if found */
|
||||
for (i = 0; i < panel->dir.len; i++)
|
||||
{
|
||||
if (strcmp (subdir, panel->dir.list[i].fname) == 0)
|
||||
if (strcmp (subdir, panel->dir.list[i].fname->str) == 0)
|
||||
{
|
||||
do_select (panel, i);
|
||||
g_free (subdir);
|
||||
@ -4120,7 +4128,7 @@ panel_save_current_file_to_clip_file (const gchar * event_group_name, const gcha
|
||||
|
||||
if (current_panel->marked == 0)
|
||||
mc_event_raise (MCEVENT_GROUP_CORE, "clipboard_text_to_file",
|
||||
(gpointer) selection (current_panel)->fname);
|
||||
(gpointer) selection (current_panel)->fname->str);
|
||||
else
|
||||
{
|
||||
int i;
|
||||
@ -4132,7 +4140,8 @@ panel_save_current_file_to_clip_file (const gchar * event_group_name, const gcha
|
||||
{ /* Skip the unmarked ones */
|
||||
if (first)
|
||||
{
|
||||
flist = g_strdup (current_panel->dir.list[i].fname);
|
||||
flist = g_strndup (current_panel->dir.list[i].fname->str,
|
||||
current_panel->dir.list[i].fname->len);
|
||||
first = FALSE;
|
||||
}
|
||||
else
|
||||
@ -4141,7 +4150,8 @@ panel_save_current_file_to_clip_file (const gchar * event_group_name, const gcha
|
||||
char *tmp;
|
||||
|
||||
tmp =
|
||||
g_strconcat (flist, "\n", current_panel->dir.list[i].fname, (char *) NULL);
|
||||
g_strconcat (flist, "\n", current_panel->dir.list[i].fname->str,
|
||||
(char *) NULL);
|
||||
g_free (flist);
|
||||
flist = tmp;
|
||||
}
|
||||
@ -4588,7 +4598,7 @@ do_file_mark (WPanel * panel, int idx, int mark)
|
||||
return;
|
||||
|
||||
/* Only '..' can't be marked, '.' isn't visible */
|
||||
if (DIR_IS_DOTDOT (panel->dir.list[idx].fname))
|
||||
if (DIR_IS_DOTDOT (panel->dir.list[idx].fname->str))
|
||||
return;
|
||||
|
||||
file_mark (panel, idx, mark);
|
||||
@ -4656,18 +4666,20 @@ void
|
||||
panel_re_sort (WPanel * panel)
|
||||
{
|
||||
char *filename;
|
||||
file_entry_t *fe;
|
||||
int i;
|
||||
|
||||
if (panel == NULL)
|
||||
return;
|
||||
|
||||
filename = g_strdup (selection (panel)->fname);
|
||||
fe = selection (panel);
|
||||
filename = g_strndup (fe->fname->str, fe->fname->len);
|
||||
unselect_item (panel);
|
||||
dir_list_sort (&panel->dir, panel->sort_field->sort_routine, &panel->sort_info);
|
||||
panel->selected = -1;
|
||||
|
||||
for (i = panel->dir.len; i != 0; i--)
|
||||
if (strcmp (panel->dir.list[i - 1].fname, filename) == 0)
|
||||
if (strcmp (panel->dir.list[i - 1].fname->str, filename) == 0)
|
||||
{
|
||||
panel->selected = i - 1;
|
||||
break;
|
||||
@ -4694,7 +4706,8 @@ panel_set_sort_order (WPanel * panel, const panel_field_t * sort_order)
|
||||
{
|
||||
char *current_file;
|
||||
|
||||
current_file = g_strdup (panel->dir.list[panel->selected].fname);
|
||||
current_file = g_strndup (panel->dir.list[panel->selected].fname->str,
|
||||
panel->dir.list[panel->selected].fname->len);
|
||||
panel_reload (panel);
|
||||
try_to_select (panel, current_file);
|
||||
g_free (current_file);
|
||||
|
@ -460,23 +460,17 @@ do_panelize_cd (WPanel * panel)
|
||||
|
||||
for (i = 0; i < panelized_panel.list.len; i++)
|
||||
{
|
||||
if (panelized_same || DIR_IS_DOTDOT (panelized_panel.list.list[i].fname))
|
||||
{
|
||||
list->list[i].fnamelen = panelized_panel.list.list[i].fnamelen;
|
||||
list->list[i].fname = g_strndup (panelized_panel.list.list[i].fname,
|
||||
panelized_panel.list.list[i].fnamelen);
|
||||
}
|
||||
if (panelized_same || DIR_IS_DOTDOT (panelized_panel.list.list[i].fname->str))
|
||||
list->list[i].fname = g_string_new_len (panelized_panel.list.list[i].fname->str,
|
||||
panelized_panel.list.list[i].fname->len);
|
||||
else
|
||||
{
|
||||
vfs_path_t *tmp_vpath;
|
||||
char *fname;
|
||||
|
||||
tmp_vpath =
|
||||
vfs_path_append_new (panelized_panel.root_vpath, panelized_panel.list.list[i].fname,
|
||||
(char *) NULL);
|
||||
fname = vfs_path_free (tmp_vpath, FALSE);
|
||||
list->list[i].fnamelen = strlen (fname);
|
||||
list->list[i].fname = fname;
|
||||
vfs_path_append_new (panelized_panel.root_vpath,
|
||||
panelized_panel.list.list[i].fname->str, (char *) NULL);
|
||||
list->list[i].fname = g_string_new (vfs_path_free (tmp_vpath, FALSE));
|
||||
}
|
||||
list->list[i].f.link_to_dir = panelized_panel.list.list[i].f.link_to_dir;
|
||||
list->list[i].f.stale_link = panelized_panel.list.list[i].f.stale_link;
|
||||
@ -529,9 +523,8 @@ panelize_save_panel (WPanel * panel)
|
||||
|
||||
for (i = 0; i < panel->dir.len; i++)
|
||||
{
|
||||
panelized_panel.list.list[i].fnamelen = list->list[i].fnamelen;
|
||||
panelized_panel.list.list[i].fname =
|
||||
g_strndup (list->list[i].fname, list->list[i].fnamelen);
|
||||
g_string_new_len (list->list[i].fname->str, list->list[i].fname->len);
|
||||
panelized_panel.list.list[i].f.link_to_dir = list->list[i].f.link_to_dir;
|
||||
panelized_panel.list.list[i].f.stale_link = list->list[i].f.stale_link;
|
||||
panelized_panel.list.list[i].f.dir_size_computed = list->list[i].f.dir_size_computed;
|
||||
@ -568,7 +561,7 @@ panelize_absolutize_if_needed (WPanel * panel)
|
||||
|
||||
/* Note: We don't support mixing of absolute and relative paths, which is
|
||||
* why it's ok for us to check only the 1st entry. */
|
||||
if (list->len > 1 && g_path_is_absolute (list->list[1].fname))
|
||||
if (list->len > 1 && g_path_is_absolute (list->list[1].fname->str))
|
||||
{
|
||||
vfs_path_t *root;
|
||||
|
||||
|
@ -255,7 +255,7 @@ test_condition (const WEdit * edit_widget, char *p, gboolean * condition)
|
||||
else
|
||||
#endif
|
||||
*condition = panel != NULL &&
|
||||
mc_search (arg, DEFAULT_CHARSET, panel->dir.list[panel->selected].fname,
|
||||
mc_search (arg, DEFAULT_CHARSET, panel->dir.list[panel->selected].fname->str,
|
||||
search_type);
|
||||
break;
|
||||
case 'y': /* syntax pattern */
|
||||
@ -774,7 +774,7 @@ expand_format (const WEdit * edit_widget, char c, gboolean do_quote)
|
||||
panel = other_panel;
|
||||
}
|
||||
|
||||
fname = panel->dir.list[panel->selected].fname;
|
||||
fname = panel->dir.list[panel->selected].fname->str;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -916,7 +916,7 @@ expand_format (const WEdit * edit_widget, char c, gboolean do_quote)
|
||||
{
|
||||
char *tmp;
|
||||
|
||||
tmp = quote_func (panel->dir.list[i].fname, FALSE);
|
||||
tmp = quote_func (panel->dir.list[i].fname->str, FALSE);
|
||||
g_string_append (block, tmp);
|
||||
g_string_append_c (block, ' ');
|
||||
g_free (tmp);
|
||||
|
@ -211,7 +211,7 @@ mcview_hook (void *v)
|
||||
|
||||
mcview_done (view);
|
||||
mcview_init (view);
|
||||
mcview_load (view, 0, panel->dir.list[panel->selected].fname, 0, 0, 0);
|
||||
mcview_load (view, 0, panel->dir.list[panel->selected].fname->str, 0, 0, 0);
|
||||
mcview_display (view);
|
||||
}
|
||||
|
||||
@ -321,7 +321,7 @@ mcview_load_next_prev_init (WView * view)
|
||||
{
|
||||
const file_entry_t *fe = &view->dir->list[i];
|
||||
|
||||
if (fname_len == fe->fnamelen && strncmp (fname, fe->fname, fname_len) == 0)
|
||||
if (fname_len == fe->fname->len && strncmp (fname, fe->fname->str, fname_len) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
@ -374,7 +374,8 @@ mcview_load_next_prev (WView * view, int direction)
|
||||
dir_idx = view->dir_idx;
|
||||
view->dir = NULL;
|
||||
view->dir_idx = NULL;
|
||||
vfile = vfs_path_append_new (view->workdir_vpath, dir->list[*dir_idx].fname, (char *) NULL);
|
||||
vfile =
|
||||
vfs_path_append_new (view->workdir_vpath, dir->list[*dir_idx].fname->str, (char *) NULL);
|
||||
mcview_done (view);
|
||||
mcview_remove_ext_script (view);
|
||||
mcview_init (view);
|
||||
|
@ -76,10 +76,10 @@ START_TEST (sanitize_variables)
|
||||
|
||||
current_panel->selected = 0;
|
||||
current_panel->dir.len = 3;
|
||||
current_panel->dir.list[0].fname = (char *) "selected file.txt";
|
||||
current_panel->dir.list[1].fname = (char *) "tagged file1.txt";
|
||||
current_panel->dir.list[0].fname = g_string_new ("selected file.txt");
|
||||
current_panel->dir.list[1].fname = g_string_new ("tagged file1.txt");
|
||||
current_panel->dir.list[1].f.marked = TRUE;
|
||||
current_panel->dir.list[2].fname = (char *) "tagged file2.txt";
|
||||
current_panel->dir.list[2].fname = g_string_new ("tagged file2.txt");
|
||||
current_panel->dir.list[2].f.marked = TRUE;
|
||||
|
||||
/* when */
|
||||
@ -103,6 +103,9 @@ export MC_EXT_ONLYTAGGED\n";
|
||||
mctest_assert_str_eq (actual_string->str, expected_string);
|
||||
|
||||
g_string_free (actual_string, TRUE);
|
||||
g_string_free (current_panel->dir.list[0].fname, TRUE);
|
||||
g_string_free (current_panel->dir.list[1].fname, TRUE);
|
||||
g_string_free (current_panel->dir.list[2].fname, TRUE);
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
|
Loading…
x
Reference in New Issue
Block a user