-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_print_simple.c
86 lines (80 loc) · 2.13 KB
/
ft_print_simple.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
86
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_print_simple.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tmaraval <tmaraval@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/12/14 08:35:35 by tmaraval #+# #+# */
/* Updated: 2018/01/05 17:07:22 by tmaraval ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_ls.h"
void ft_print_simple(t_dirfile *last, t_opt *opt)
{
while (last)
{
ft_print_fname(last);
if (ft_strlen(last->owner) != 0)
ft_strdel(&(last->owner));
if (ft_strlen(last->group) != 0)
ft_strdel(&(last->group));
opt->l = opt->l;
ft_putendl("");
last = last->next;
}
}
void ft_print_path(char *path, int rec)
{
if (rec == TRUE)
{
ft_putstr(".");
if (path[0] != '/')
ft_putstr("/");
ft_putstr(path);
ft_putendl(":");
}
else
{
ft_putstr(path);
ft_putendl(":");
}
}
void ft_print_sizeormajmin(t_dirfile *last, t_maxvalue max)
{
char *ptr;
static int space;
if (last->type == 'b' || last->type == 'c')
{
ft_putstr(" ");
ptr = ft_itoa(last->major);
space = ft_printspace(max.maj, ft_strlen(ptr));
free(ptr);
ft_putnbr(last->major);
ft_putstr(", ");
ptr = ft_itoa(last->minor);
space = space + ft_printspace(max.min, ft_strlen(ptr));
ft_putnbr(last->minor);
space = space + 3;
}
else
{
ft_putstr(" ");
ft_printspace(space, 0);
ptr = ft_itoa(last->size);
ft_printspace(max.size, ft_strlen(ptr));
ft_putnbr(last->size);
}
free(ptr);
}
void ft_lst_print_ln(t_dirfile *last)
{
if (last->type == 'l')
{
ft_putstr(" -> ");
ft_putstr(last->lnpath);
ft_putendl("");
}
else
ft_putendl("");
}