-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathls_print_prepare.c
78 lines (68 loc) · 2.33 KB
/
ls_print_prepare.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ls_print_prepare.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: alischyn <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/26 18:39:33 by alischyn #+# #+# */
/* Updated: 2017/03/26 18:56:53 by alischyn ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_ls.h"
static int ft_max(int a, int b)
{
return (a > b ? a : b);
}
void ls_print_list_prepare_nlinks_pad(t_list *list)
{
int i;
int padding;
padding = 0;
i = -1;
while (++i < list->items.length)
padding = ft_max(padding,
strlen(VEC_NTH(&list->items, i, t_fileinfo *)->fmt_nlinks));
i = -1;
while (++i < list->items.length)
VEC_NTH(&list->items, i, t_fileinfo *)->fmt_nlinks_pad = padding;
}
void ls_print_list_prepare_owner_name_pad(t_list *list)
{
int i;
int padding;
padding = 0;
i = -1;
while (++i < list->items.length)
padding = ft_max(padding,
strlen(VEC_NTH(&list->items, i, t_fileinfo *)->fmt_owner_name));
i = -1;
while (++i < list->items.length)
VEC_NTH(&list->items, i, t_fileinfo *)->fmt_owner_name_pad = padding;
}
void ls_print_list_prepare_owner_group_pad(t_list *list)
{
int i;
int padding;
padding = 0;
i = -1;
while (++i < list->items.length)
padding = ft_max(padding,
strlen(VEC_NTH(&list->items, i, t_fileinfo *)->fmt_owner_group));
i = -1;
while (++i < list->items.length)
VEC_NTH(&list->items, i, t_fileinfo *)->fmt_owner_group_pad = padding;
}
void ls_print_list_prepare_size_pad(t_list *list)
{
int i;
int padding;
padding = 0;
i = -1;
while (++i < list->items.length)
padding = ft_max(padding,
strlen(VEC_NTH(&list->items, i, t_fileinfo *)->fmt_size));
i = -1;
while (++i < list->items.length)
VEC_NTH(&list->items, i, t_fileinfo *)->fmt_size_pad = padding;
}