示例#1
0
文件: ftls_list.c 项目: Lefr0g/ft_ls
int		ftls_add_entry(t_list **alst, t_env *e, char *name, char *prefix)
{
	struct stat	statbuf;
	char		*path;
	t_entry		entry;
	t_list		*lst_ptr;

	path = (prefix) ? ft_strjoin(prefix, name) : ft_strdup(name);
	if (ftls_get_file_status(e, &statbuf, &path))
		return (1);
	ftls_copy_details(&entry, &statbuf, name, prefix);
	if (e->showlist)
		ftls_copy_details_sub2(e, &entry, &statbuf);
	ftls_manage_time_ptr(e, &entry);
	if (ftls_is_entry_showable(e, &entry) && (e->atleastonetoshow = 1))
		e->totalblocks += entry.st_blocks;
	if (e->showlist && ftls_is_entry_showable(e, &entry))
		ftls_get_column_metadata(e, &entry);
	if ((entry.st_mode & S_IFLNK) == S_IFLNK)
		ftls_get_linktarget(&entry, path);
	ft_strdel(&path);
	lst_ptr = ft_lstnew(&entry, sizeof(t_entry));
	*alst ? ft_lstappend(alst, lst_ptr) : (*alst = lst_ptr);
	e->col_len = ft_getmax(e->col_len,
			ft_getmin(ft_strlen(name), e->termwidth));
	return (0);
}
示例#2
0
int		ftpf_manage_field_width(t_ftpf_env *e)
{
	int	i;

	i = e->field_width;
	if (e->zero && e->isneg && !e->precision)
	{
		ft_putchar(FW_MINUS);
		e->isneg = !e->isneg;
	}
	while (i && i - ft_getmax(e->outputlen, e->precision) > 0)
	{
		if (DEBUG_MODE)
			ft_putchar('w');
		else
			ft_putchar(e->spacer);
		i--;
	}
	return (0);
}
示例#3
0
int					ft_keycmp(int buffer)
{
	ft_arrows(buffer);
	if (buffer == SPACE)
	{
		singleton()->current->selected ^= 1;
		singleton()->current = singleton()->current->next;
	}
	if (buffer == DELETE || buffer == BACKSPACE)
	{
		if (singleton()->current->first == 1)
			singleton()->clst = singleton()->clst->next;
		ft_clstdelone(&singleton()->current);
		if (!singleton()->current)
			ft_reset();
		ft_getmax(singleton()->clst);
	}
	if (buffer == ESCAPE)
		ft_reset();
	if (buffer == RETURN)
		ft_returnslct();
	return (1);
}