-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_handle_output.c
52 lines (48 loc) · 1.69 KB
/
ft_handle_output.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_handle_output.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: pdecrat <pdecrat@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/12/17 15:43:46 by pdecrat #+# #+# */
/* Updated: 2015/02/25 12:43:41 by pdecrat ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_ls.h"
t_list *ft_del_files(t_core *core)
{
t_list *cursor;
t_list *tmp;
cursor = OUTPUT;
while (cursor)
{
tmp = cursor->next;
if (!(ft_strchr(OPT, 'R'))
|| !(ft_strcmp(ft_strrchr(cursor->content, '/'), "/."))
|| !(ft_strcmp(ft_strrchr(cursor->content, '/'), "/.."))
|| (ft_is_file_foo(cursor->content, "link"))
|| (ft_is_dir(cursor->content)) != 1)
ft_lstfreeone(&OUTPUT, &cursor);
cursor = tmp;
}
return (OUTPUT);
}
int ft_handle_output(t_core *core)
{
if (OUTPUT)
{
OUTPUT = ft_ls_sort(core);
(ft_strchr(OPT, 'l')) ? ft_long_display(core) : ft_ls_display(core);
OUTPUT = ft_del_files(core);
}
if (OUTPUT && ft_strchr(OPT, 'R'))
{
if (PENDING)
PENDING = ft_lstjoin(&PENDING, OUTPUT);
else
PENDING = ft_lstcpy_and_del(OUTPUT);
OUTPUT = NULL;
}
return (0);
}