-
Notifications
You must be signed in to change notification settings - Fork 0
/
fileinfo_cmp.c
51 lines (45 loc) · 1.67 KB
/
fileinfo_cmp.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* fileinfo_cmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rishimot <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/12/04 23:43:53 by rishimot #+# #+# */
/* Updated: 2020/12/04 23:43:55 by rishimot ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_mini_ls.h"
int filetime_cmp(t_list *lst, t_file_info *nf)
{
int len;
t_file_info *of;
len = ft_strlen(nf->name);
of = (t_file_info*)lst->content;
if (of->time.tv_sec > nf->time.tv_sec)
return (1);
else if (of->time.tv_sec == nf->time.tv_sec)
{
if (of->time.tv_nsec > nf->time.tv_nsec)
return (1);
else if (of->time.tv_nsec == nf->time.tv_nsec)
if (ft_strncmp(nf->name, of->name, len) >= 0)
return (1);
}
return (0);
}
int filesize_cmp(t_list *lst, t_file_info *nf)
{
int len;
t_file_info *of;
len = ft_strlen(nf->name);
of = (t_file_info*)lst->content;
if (of->size > nf->size)
return (1);
else if (of->size == nf->size)
{
if (ft_strncmp(nf->name, of->name, len) >= 0)
return (1);
}
return (0);
}