-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtriflib.h
89 lines (80 loc) · 2.35 KB
/
triflib.h
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
87
88
89
#ifndef TRIFLIB_H
#define TRIFLIB_H
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
typedef struct t_dir_list
{
struct t_node *ptr;
struct t_dir_list *next;
} t_dir_list;
void printhelp();
void tab();
void hyphen();
void enqueue(t_dir_list **front, t_dir_list **rear, struct t_node *ptr);
void dequeue(t_dir_list **front, t_dir_list **rear);
struct t_node *front_top(t_dir_list *front);
void tab()
{
printf(" ");
}
void hyphen()
{
printf("│ ");
}
void enqueue(t_dir_list **front_ptr, t_dir_list **rear_ptr, struct t_node *ptr)
{
if (*front_ptr == NULL && *front_ptr == NULL)
{
t_dir_list *node = (t_dir_list *)malloc(sizeof(t_dir_list));
node->ptr = ptr;
node->next = NULL;
*front_ptr = node;
*rear_ptr = node;
return;
}
t_dir_list *node = (t_dir_list *)malloc(sizeof(t_dir_list));
node->ptr = ptr;
node->next = NULL;
(*rear_ptr)->next = node;
*rear_ptr = node;
}
void dequeue(t_dir_list **front_ptr, t_dir_list **rear_ptr)
{
if (*front_ptr == NULL)
{
return;
}
t_dir_list *tmp = (*front_ptr);
(*front_ptr) = (*front_ptr)->next;
free(tmp);
if (*front_ptr == NULL)
{
*rear_ptr = NULL;
}
}
void printhelp()
{
fprintf(stdout, "Usage: trif [OPTION] ..... [DIRECTORY] .....\n");
fprintf(stdout, "\n-d, --directory-only List directories only.\n");
fprintf(stdout, "-f, --full-path Print the full path prefix for each file.\n");
fprintf(stdout, "-P, --pattern List only those files that match the pattern given.\n");
fprintf(stdout, " -P <string>\n");
fprintf(stdout, "-D, --difference Print the difference between folders.\n");
fprintf(stdout, "-s, --sync Sync the folders.\n");
fprintf(stdout, "-L,--level Descend only level directories deep.\n");
fprintf(stdout, " -L <positive integer>\n");
fprintf(stdout, "-r,--remove-duplicate Move the duplicate files to trash\n");
fprintf(stdout, "--file-type List only files of given file type.\n");
fprintf(stdout, " --file-type=<fileformat> \n");
fprintf(stdout, "--help Print usage and this help message and exit.\n\n");
}
struct t_node *front_top(t_dir_list *front)
{
if (front != NULL)
{
return front->ptr;
}
return NULL;
}
#endif