-
Notifications
You must be signed in to change notification settings - Fork 0
/
test2.c
56 lines (42 loc) · 1.23 KB
/
test2.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
#include <stdio.h>
#include <comp421/iolib.h>
#include <comp421/filesystem.h>
#include <comp421/yalnix.h>
int main(int argc, char **argv) {
(void)argc;
(void)argv;
int i;
char buf1[DIRNAMELEN];
char buf2[DIRNAMELEN];
for (i = 0; i < 10; i++) {
sprintf(buf1, "%d", i);
sprintf(buf2, ".");
printf("Making directory %d\n", i);
if (MkDir(buf1)) {
printf("Something went wrong making directory %d\n", i);
return ERROR;
}
printf("Changing to directory %d\n", i);
if (ChDir(buf1) == ERROR) {
printf("Something went wrong changing to directory %d\n", i);
return ERROR;
}
}
for (i = 9; i >= 0; i--) {
sprintf(buf1, "%d", i);
sprintf(buf2, "..");
printf("Changing to parent directory\n");
if (ChDir(buf2)) {
printf("Something went wrong changing to parent directory\n");
return ERROR;
}
printf("Removing directory %d\n", i);
if (RmDir(buf1)) {
printf("Something went wrong removing directory %i\n", i);
return ERROR;
}
}
printf("Created all directories\n");
Shutdown();
return 0;
}