-
Notifications
You must be signed in to change notification settings - Fork 0
/
process_path2.c
65 lines (59 loc) · 2.08 KB
/
process_path2.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* process_path2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mtacnet <mtacnet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/06/17 15:04:16 by mtacnet #+# #+# */
/* Updated: 2017/06/19 17:01:20 by mtacnet ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_ls.h"
void t_opt1(t_flags *flags, t_elem **lst_dname, char *dname,
struct stat stat)
{
if (flags->t_flag)
*lst_dname = push_name_sortime(*lst_dname, dname, stat);
else
*lst_dname = push_infos_name(*lst_dname, dname, stat);
}
void t_opt2(t_flags *flags, t_elem **lst_dir, char *dname, struct stat stat)
{
if (flags->t_flag)
*lst_dir = push_name_sortime(*lst_dir, dname, stat);
else
*lst_dir = push_infos_name(*lst_dir, dname, stat);
}
char *concat_str(char *str, char *dname, t_env *env)
{
str = ft_strjoin(env->path, "/");
str = ft_strjoin(str, dname);
return (str);
}
void print(t_flags *flags, t_elem *lst_dname, t_elem *lst_dir, t_env *env)
{
closedir(env->dir_path);
process_size(lst_dname, env);
if (flags->r_flag)
print_reverse_list_name(lst_dname, flags, env);
else
print_lst_name(lst_dname, flags, env);
if (flags->br_flag)
{
lst_dir = reverse_lst(&lst_dir, flags);
while (lst_dir != NULL)
{
rec_dir(env->path, lst_dir->name, flags);
lst_dir = lst_dir->next;
}
}
}
void process_env(t_env *env, char *path)
{
init_struct_env(env);
env->path = NULL;
env->path = ft_strnew(ft_strlen(path));
env->path = ft_strcpy(env->path, path);
env->dir_path = opendir(path);
}