-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
39 lines (30 loc) · 943 Bytes
/
main.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
#include "bf_search.h"
#include "queue.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(int argc, char *argv[]) {
if (argc != 3) {
fprintf(stderr, "Usage: %s <start_path> <target_file>\n", argv[0]);
return EXIT_FAILURE;
}
float startTime, endTime, timeElapsed;
const char *start_path = argv[1];
const char *target_file = argv[2];
startTime = (float)clock() / CLOCKS_PER_SEC;
SearchResult result = BFSearch(start_path, target_file);
endTime = (float)clock() / CLOCKS_PER_SEC;
if (result.num_paths > 0) {
printf("Found %d file(s):\n", result.num_paths);
for (int i = 0; i < result.num_paths; ++i) {
printf("%s\n", result.paths[i]);
}
// Free the memory allocated for the result
freeSearchResult(&result);
} else {
printf("File %s not found.\n", target_file);
}
timeElapsed = endTime - startTime;
printf("Time Elapsed %f\n", timeElapsed);
return 0;
}