Example #1
0
static void		the_following(char ***av, char *option, int mode)
{
	if (mode == 1)
		skip_option(av);
	ascii_sort((*av));
	check_error((*av));
	if (mode == 1)
	{
		if (IS_T && !(IS_F))
			mod_time_sort((*av) + arg((*av), 0));
		else if (!(IS_F) && !(IS_T))
			ascii_sort((*av));
		(IS_R_2 && !(IS_F)) ? rev_sort((*av) + arg((*av), 0)) : 0;
	}
	display_all(*av, option);
}
Example #2
0
void			ls_one(char *file, char *option)
{
	DIR			*dir;
	t_dirent	*folder;
	char		**tab;
	int			folder_len;
	int			j;

	j = 0;
	folder = NULL;
	if ((folder_len = count_nb_file(file)) == -1)
		display_eacces(file);
	else
	{
		(!(dir = opendir(file))) ? perror_opendir() : 0;
		if (!(tab = (char**)malloc(sizeof(*tab) * (folder_len + 1))))
			perror_malloc();
		while ((folder = readdir(dir)))
			tab[j++] = ft_strjoin_path(file, folder->d_name);
		tab[j] = NULL;
		(closedir(dir) == -1) ? perror_closedir() : 0;
		(IS_T && !(IS_F)) ? mod_time_sort(tab) : 0;
		(!(IS_F) && !(IS_T)) ? ascii_sort(tab) : 0;
		(IS_R_2 && !(IS_F)) ? rev_sort(tab) : 0;
		display_file(tab, option);
		free_string_array(&tab);
	}
}
Example #3
0
void		sort(t_env *e, t_info *to_add, t_info **begin)
{
	if (e->lowercase_r && e->t)
	 	reverse_time_sort(begin, to_add);
	else if (e->t)
		time_sort(begin, to_add);
	else if (e->lowercase_r)
		reverse_sort(begin, to_add);
	else
		ascii_sort(begin, to_add);
}