-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmi_ls.c
More file actions
50 lines (43 loc) · 1.01 KB
/
Copy pathmi_ls.c
File metadata and controls
50 lines (43 loc) · 1.01 KB
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
/*
Autores:
- Marc Link Cladera
- Carlos Gálvez Mena
- Jesús Castillo Benito
*/
#include "directorios.h"
int main(int argc, char **args)
{
if (argc < 3 || argc > 4 || (argc == 4 && strcmp(args[1], "-l") != 0))
{
fprintf(
stderr,
RED
"ERROR: invalid syntax. Usage: ./mi_ls [-l] <disco> </ruta>\n"
RESET
);
return FALLO;
}
char type = ' ';
char flag = ' ';
char buffer[TAMBUFFER];
char *path;
char *disco;
if (argc == 4)
{
path = args[3];
disco = args[2];
flag = 'l';
if (args[3][strlen(args[3]) - 1] != '/') type = 'f';
else type = 'd';
} else if (argc == 3)
{
path = args[2];
disco = args[1];
if (args[2][strlen(args[2]) - 1] != '/') type = 'f';
else type = 'd';
}
if (bmount(disco) < 0) return FALLO;
mi_dir(path, buffer, type, flag);
printf("%s\n", buffer);
if (bumount()) return FALLO;
}