-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_show_files.c
70 lines (62 loc) · 1.9 KB
/
ft_show_files.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_show_files.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lscariot <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/01/26 08:41:44 by lscariot #+# #+# */
/* Updated: 2016/02/27 12:05:51 by lscariot ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_ls.h"
void ft_spaceput(int s, char *str)
{
int len;
len = (s - ft_strlen(str)) + 1;
ft_putchar(' ');
ft_putstr(str);
ft_putnchar(' ', len);
}
void ft_putspace(int s, char *str)
{
int len;
len = (s - ft_strlen(str)) + 1;
ft_putnchar(' ', len);
ft_putstr(str);
}
void ft_show_l(t_files *files, t_lenmax max)
{
ft_putstr(files->modes);
ft_putspace(max.links, files->links);
ft_spaceput(max.user, files->user);
ft_spaceput(max.group - 2, files->group);
ft_putspace(max.size, files->size);
ft_putspace(max.month, files->month);
ft_putspace(max.number, files->number);
ft_putspace(max.hour, files->hour);
ft_putstr(" ");
}
void ft_show_files(char *fl, t_files *files, t_args args, int err)
{
t_files *tmp;
static int i;
t_lenmax max;
ft_file_name_norme(fl, args, &i, err);
i++;
if (files == NULL)
return ;
if (args.l)
{
max = ft_maxlen(files);
ft_count_total(files);
}
while (files != NULL)
{
if (args.l)
ft_show_l(files, max);
ft_putendl(files->name);
tmp = files;
files = files->next;
}
}