-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_add.c
executable file
·85 lines (76 loc) · 1.97 KB
/
ft_add.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_add.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ade-bonn <ade-bonn@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/11/25 09:23:28 by ade-bonn #+# #+# */
/* Updated: 2014/12/02 04:44:23 by ade-bonn ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_ls.h"
void ft_ls(t_steve *list, t_opts *opt)
{
while (list != NULL)
{
if (opt->a == 0 && list->file[0] != '.')
ft_putendl(list->file);
else if (opt->a)
ft_putendl(list->file);
list = list->next;
}
}
void ft_add_gr(t_steve *list, t_opts *opt)
{
int rec;
t_steve *tmp;
rec = 0;
while (list != NULL)
{
tmp = NULL;
if (opt->l == 0)
ft_ls_l(list);
if (list->access[0] == 'd' && ft_strcmp(list->file, ".") != 0
&& ft_strcmp(list->file, "..") != 0)
{
ft_putchar('\n');
ft_putstr(list->path);
ft_putendl(":");
ft_find(list->path, &tmp, opt, rec);
}
list = list->next;
}
}
void ft_add_ls(t_steve *list, t_opts *opt)
{
if (opt->r)
ft_r(&list, opt);
if (opt->l)
ft_l(list, opt);
else
ft_ls(list, opt);
if (opt->gr)
ft_add_gr(list, opt);
}
void ft_add_r(t_steve **list, t_steve *normal)
{
t_steve *tmp;
while (normal)
{
tmp = normal->next;
normal->next = *list;
*list = normal;
normal = tmp;
}
}
void ft_r(t_steve **list, t_opts *opt)
{
t_steve *normal;
if (opt->r)
{
normal = *list;
*list = NULL;
ft_add_r(list, normal);
}
}