-
Notifications
You must be signed in to change notification settings - Fork 0
/
tools.c
62 lines (55 loc) · 1.57 KB
/
tools.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* tools.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: qdegraev <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/03/08 01:57:22 by qdegraev #+# #+# */
/* Updated: 2016/03/13 15:05:50 by qdegraev ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_ls.h"
int ft_num_len(size_t num)
{
int i;
i = 0;
if (num == 0)
return (0);
while ((num = num / 10))
i++;
return (i + 1);
}
int ft_isnavdir(char *name)
{
if (!name)
return (0);
if (name[0] == '.' && (!name[1] || name[1] == '.'))
return (1);
else
return (0);
}
int ft_ishidden(char *name)
{
if (!name)
return (0);
if (name[0] == '.' && !ft_isnavdir(name))
return (1);
else
return (0);
}
void del_listone(t_list **sort)
{
t_list *tmp;
t_dircont *dc;
tmp = (*sort)->next ? (*sort)->next : (*sort);
dc = tmp->content;
if (dc->name)
ft_strdel(&dc->name);
if (dc->type)
ft_strdel(&dc->type);
if (dc->path)
ft_strdel(&dc->path);
free(*sort);
*sort = tmp;
}