(handle_path): don't check list size here.
(handle_dirent): likewise. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Этот коммит содержится в:
родитель
6a3943fcf0
Коммит
a774019250
@ -140,21 +140,21 @@ clean_sort_keys (dir_list * list, int start, int count)
|
|||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
/**
|
/**
|
||||||
* If you change handle_dirent then check also handle_path.
|
* If you change handle_dirent then check also handle_path.
|
||||||
* @return -1 = failure, 0 = don't add, 1 = add to the list
|
* @return FALSE = don't add, TRUE = add to the list
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int
|
static gboolean
|
||||||
handle_dirent (dir_list * list, const char *fltr, struct dirent *dp,
|
handle_dirent (struct dirent *dp, const char *fltr, struct stat *buf1, int *link_to_dir,
|
||||||
struct stat *buf1, int next_free, int *link_to_dir, int *stale_link)
|
int *stale_link)
|
||||||
{
|
{
|
||||||
vfs_path_t *vpath;
|
vfs_path_t *vpath;
|
||||||
|
|
||||||
if (DIR_IS_DOT (dp->d_name) || DIR_IS_DOTDOT (dp->d_name))
|
if (DIR_IS_DOT (dp->d_name) || DIR_IS_DOTDOT (dp->d_name))
|
||||||
return 0;
|
return FALSE;
|
||||||
if (!panels_options.show_dot_files && (dp->d_name[0] == '.'))
|
if (!panels_options.show_dot_files && (dp->d_name[0] == '.'))
|
||||||
return 0;
|
return FALSE;
|
||||||
if (!panels_options.show_backups && dp->d_name[NLENGTH (dp) - 1] == '~')
|
if (!panels_options.show_backups && dp->d_name[strlen (dp->d_name) - 1] == '~')
|
||||||
return 0;
|
return FALSE;
|
||||||
|
|
||||||
vpath = vfs_path_from_str (dp->d_name);
|
vpath = vfs_path_from_str (dp->d_name);
|
||||||
if (mc_lstat (vpath, buf1) == -1)
|
if (mc_lstat (vpath, buf1) == -1)
|
||||||
@ -176,21 +176,17 @@ handle_dirent (dir_list * list, const char *fltr, struct dirent *dp,
|
|||||||
if (S_ISLNK (buf1->st_mode))
|
if (S_ISLNK (buf1->st_mode))
|
||||||
{
|
{
|
||||||
struct stat buf2;
|
struct stat buf2;
|
||||||
|
|
||||||
if (mc_stat (vpath, &buf2) == 0)
|
if (mc_stat (vpath, &buf2) == 0)
|
||||||
*link_to_dir = S_ISDIR (buf2.st_mode) != 0;
|
*link_to_dir = S_ISDIR (buf2.st_mode) != 0;
|
||||||
else
|
else
|
||||||
*stale_link = 1;
|
*stale_link = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
vfs_path_free (vpath);
|
vfs_path_free (vpath);
|
||||||
if (!(S_ISDIR (buf1->st_mode) || *link_to_dir) && (fltr != NULL)
|
|
||||||
&& !mc_search (fltr, dp->d_name, MC_SEARCH_T_GLOB))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* Need to grow the *list? */
|
return (S_ISDIR (buf1->st_mode) || *link_to_dir != 0 || fltr == NULL
|
||||||
if (next_free == list->size && !dir_list_grow (list, RESIZE_STEPS))
|
|| mc_search (fltr, dp->d_name, MC_SEARCH_T_GLOB));
|
||||||
return -1;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
@ -516,22 +512,21 @@ set_zero_dir (dir_list * list)
|
|||||||
and panels_options.show_backups.
|
and panels_options.show_backups.
|
||||||
Moreover handle_path can't be used with a filemask.
|
Moreover handle_path can't be used with a filemask.
|
||||||
If you change handle_path then check also handle_dirent. */
|
If you change handle_path then check also handle_dirent. */
|
||||||
/* Return values: -1 = failure, 0 = don't add, 1 = add to the list */
|
/* Return values: FALSE = don't add, TRUE = add to the list */
|
||||||
|
|
||||||
int
|
gboolean
|
||||||
handle_path (dir_list * list, const char *path,
|
handle_path (const char *path, struct stat *buf1, int *link_to_dir, int *stale_link)
|
||||||
struct stat *buf1, int next_free, int *link_to_dir, int *stale_link)
|
|
||||||
{
|
{
|
||||||
vfs_path_t *vpath;
|
vfs_path_t *vpath;
|
||||||
|
|
||||||
if (DIR_IS_DOT (path) || DIR_IS_DOTDOT (path))
|
if (DIR_IS_DOT (path) || DIR_IS_DOTDOT (path))
|
||||||
return 0;
|
return FALSE;
|
||||||
|
|
||||||
vpath = vfs_path_from_str (path);
|
vpath = vfs_path_from_str (path);
|
||||||
if (mc_lstat (vpath, buf1) == -1)
|
if (mc_lstat (vpath, buf1) == -1)
|
||||||
{
|
{
|
||||||
vfs_path_free (vpath);
|
vfs_path_free (vpath);
|
||||||
return 0;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (S_ISDIR (buf1->st_mode))
|
if (S_ISDIR (buf1->st_mode))
|
||||||
@ -543,6 +538,7 @@ handle_path (dir_list * list, const char *path,
|
|||||||
if (S_ISLNK (buf1->st_mode))
|
if (S_ISLNK (buf1->st_mode))
|
||||||
{
|
{
|
||||||
struct stat buf2;
|
struct stat buf2;
|
||||||
|
|
||||||
if (mc_stat (vpath, &buf2) == 0)
|
if (mc_stat (vpath, &buf2) == 0)
|
||||||
*link_to_dir = S_ISDIR (buf2.st_mode) != 0;
|
*link_to_dir = S_ISDIR (buf2.st_mode) != 0;
|
||||||
else
|
else
|
||||||
@ -551,11 +547,7 @@ handle_path (dir_list * list, const char *path,
|
|||||||
|
|
||||||
vfs_path_free (vpath);
|
vfs_path_free (vpath);
|
||||||
|
|
||||||
/* Need to grow the *list? */
|
return TRUE;
|
||||||
if (next_free == list->size && !dir_list_grow (list, RESIZE_STEPS))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
@ -566,7 +558,7 @@ do_load_dir (const vfs_path_t * vpath, dir_list * list, GCompareFunc sort,
|
|||||||
{
|
{
|
||||||
DIR *dirp;
|
DIR *dirp;
|
||||||
struct dirent *dp;
|
struct dirent *dp;
|
||||||
int status, link_to_dir, stale_link;
|
int link_to_dir, stale_link;
|
||||||
int next_free = 0;
|
int next_free = 0;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
@ -598,13 +590,13 @@ do_load_dir (const vfs_path_t * vpath, dir_list * list, GCompareFunc sort,
|
|||||||
|
|
||||||
while ((dp = mc_readdir (dirp)) != NULL)
|
while ((dp = mc_readdir (dirp)) != NULL)
|
||||||
{
|
{
|
||||||
status = handle_dirent (list, fltr, dp, &st, next_free, &link_to_dir, &stale_link);
|
if (!handle_dirent (dp, fltr, &st, &link_to_dir, &stale_link))
|
||||||
if (status == 0)
|
|
||||||
continue;
|
continue;
|
||||||
if (status == -1)
|
/* Need to grow the *list? */
|
||||||
|
if (next_free == list->size && !dir_list_grow (list, RESIZE_STEPS))
|
||||||
goto ret;
|
goto ret;
|
||||||
|
|
||||||
list->list[next_free].fnamelen = NLENGTH (dp);
|
list->list[next_free].fnamelen = strlen (dp->d_name);
|
||||||
list->list[next_free].fname = g_strndup (dp->d_name, list->list[next_free].fnamelen);
|
list->list[next_free].fname = g_strndup (dp->d_name, list->list[next_free].fnamelen);
|
||||||
list->list[next_free].f.marked = 0;
|
list->list[next_free].f.marked = 0;
|
||||||
list->list[next_free].f.link_to_dir = link_to_dir;
|
list->list[next_free].f.link_to_dir = link_to_dir;
|
||||||
@ -652,7 +644,7 @@ do_reload_dir (const vfs_path_t * vpath, dir_list * list, GCompareFunc sort, int
|
|||||||
DIR *dirp;
|
DIR *dirp;
|
||||||
struct dirent *dp;
|
struct dirent *dp;
|
||||||
int next_free = 0;
|
int next_free = 0;
|
||||||
int i, status, link_to_dir, stale_link;
|
int i, link_to_dir, stale_link;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
int marked_cnt;
|
int marked_cnt;
|
||||||
GHashTable *marked_files;
|
GHashTable *marked_files;
|
||||||
@ -709,10 +701,11 @@ do_reload_dir (const vfs_path_t * vpath, dir_list * list, GCompareFunc sort, int
|
|||||||
|
|
||||||
while ((dp = mc_readdir (dirp)))
|
while ((dp = mc_readdir (dirp)))
|
||||||
{
|
{
|
||||||
status = handle_dirent (list, fltr, dp, &st, next_free, &link_to_dir, &stale_link);
|
if (!handle_dirent (dp, fltr, &st, &link_to_dir, &stale_link))
|
||||||
if (status == 0)
|
|
||||||
continue;
|
continue;
|
||||||
if (status == -1)
|
|
||||||
|
/* Need to grow the *list? */
|
||||||
|
if (next_free == list->size && !dir_list_grow (list, RESIZE_STEPS))
|
||||||
{
|
{
|
||||||
mc_closedir (dirp);
|
mc_closedir (dirp);
|
||||||
/* Norbert (Feb 12, 1997):
|
/* Norbert (Feb 12, 1997):
|
||||||
@ -746,7 +739,7 @@ do_reload_dir (const vfs_path_t * vpath, dir_list * list, GCompareFunc sort, int
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
list->list[next_free].fnamelen = NLENGTH (dp);
|
list->list[next_free].fnamelen = strlen (dp->d_name);
|
||||||
list->list[next_free].fname = g_strndup (dp->d_name, list->list[next_free].fnamelen);
|
list->list[next_free].fname = g_strndup (dp->d_name, list->list[next_free].fnamelen);
|
||||||
list->list[next_free].f.link_to_dir = link_to_dir;
|
list->list[next_free].f.link_to_dir = link_to_dir;
|
||||||
list->list[next_free].f.stale_link = stale_link;
|
list->list[next_free].f.stale_link = stale_link;
|
||||||
|
@ -49,8 +49,7 @@ int do_reload_dir (const vfs_path_t * vpath, dir_list * list, GCompareFunc sort,
|
|||||||
const dir_sort_options_t * sort_op, const char *fltr);
|
const dir_sort_options_t * sort_op, const char *fltr);
|
||||||
void clean_dir (dir_list * list, int count);
|
void clean_dir (dir_list * list, int count);
|
||||||
gboolean set_zero_dir (dir_list * list);
|
gboolean set_zero_dir (dir_list * list);
|
||||||
int handle_path (dir_list * list, const char *path, struct stat *buf1,
|
gboolean handle_path (const char *path, struct stat *buf1, int *link_to_dir, int *stale_link);
|
||||||
int next_free, int *link_to_dir, int *stale_link);
|
|
||||||
|
|
||||||
/* Sorting functions */
|
/* Sorting functions */
|
||||||
int unsorted (file_entry * a, file_entry * b);
|
int unsorted (file_entry * a, file_entry * b);
|
||||||
|
@ -1698,7 +1698,7 @@ do_find (const char *start_dir, ssize_t start_dir_len, const char *ignore_dirs,
|
|||||||
|
|
||||||
if (return_value == B_PANELIZE && *filename)
|
if (return_value == B_PANELIZE && *filename)
|
||||||
{
|
{
|
||||||
int status, link_to_dir, stale_link;
|
int link_to_dir, stale_link;
|
||||||
int next_free = 0;
|
int next_free = 0;
|
||||||
int i;
|
int i;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
@ -1734,13 +1734,13 @@ do_find (const char *start_dir, ssize_t start_dir_len, const char *ignore_dirs,
|
|||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = handle_path (list, p, &st, next_free, &link_to_dir, &stale_link);
|
if (!handle_path (p, &st, &link_to_dir, &stale_link))
|
||||||
if (status == 0)
|
|
||||||
{
|
{
|
||||||
g_free (name);
|
g_free (name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (status == -1)
|
/* Need to grow the *list? */
|
||||||
|
if (next_free == list->size && !dir_list_grow (list, RESIZE_STEPS))
|
||||||
{
|
{
|
||||||
g_free (name);
|
g_free (name);
|
||||||
break;
|
break;
|
||||||
|
@ -311,7 +311,7 @@ remove_from_panelize (struct panelize *entry)
|
|||||||
static void
|
static void
|
||||||
do_external_panelize (char *command)
|
do_external_panelize (char *command)
|
||||||
{
|
{
|
||||||
int status, link_to_dir, stale_link;
|
int link_to_dir, stale_link;
|
||||||
int next_free = 0;
|
int next_free = 0;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
dir_list *list = ¤t_panel->dir;
|
dir_list *list = ¤t_panel->dir;
|
||||||
@ -352,11 +352,13 @@ do_external_panelize (char *command)
|
|||||||
name = line + 2;
|
name = line + 2;
|
||||||
else
|
else
|
||||||
name = line;
|
name = line;
|
||||||
status = handle_path (list, name, &st, next_free, &link_to_dir, &stale_link);
|
|
||||||
if (status == 0)
|
if (!handle_path (name, &st, &link_to_dir, &stale_link))
|
||||||
continue;
|
continue;
|
||||||
if (status == -1)
|
/* Need to grow the *list? */
|
||||||
|
if (next_free == list->size && !dir_list_grow (list, RESIZE_STEPS))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
list->list[next_free].fnamelen = strlen (name);
|
list->list[next_free].fnamelen = strlen (name);
|
||||||
list->list[next_free].fname = g_strndup (name, list->list[next_free].fnamelen);
|
list->list[next_free].fname = g_strndup (name, list->list[next_free].fnamelen);
|
||||||
file_mark (current_panel, next_free, 0);
|
file_mark (current_panel, next_free, 0);
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user