-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.c
68 lines (56 loc) · 1.72 KB
/
test.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
57
58
59
60
61
62
63
64
65
66
67
68
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <dirent.h>
#include <time.h>
int main(int argc, char* argv[]){
DIR * dir1;
DIR * dir2;
dir1 = opendir(argv[1]);
struct dirent * direntFirst;
struct dirent * direntSecond;
char * firstFile;
char * secondFile;
struct stat fileStat1;
struct stat sb = {0};
while ((direntFirst=readdir(dir1)) != NULL) {
if ( !strcmp(direntFirst->d_name, ".") || !strcmp(direntFirst->d_name, "..") )
{
// do nothing (straight logic)
} else {
firstFile = direntFirst->d_name;
printf("%s\t",firstFile);
if(stat(firstFile, &sb) == 0 && S_ISDIR(sb.st_mode)){
printf("Folder\n\n");
}else {
printf("NOT Folder\n");
if (!stat(firstFile, &fileStat1)){
/*
tu dać funkcjonalnosc jezeli
obiekt jest plikiem
*/
printf("---------------------------\n");
printf("Modyfication: \t\t%ld\n",fileStat1.st_mtime);
printf("\n\n");
dir2 = opendir(argv[1]);
while ((direntSecond=readdir(dir2)) != NULL) {
if ( !strcmp(direntSecond->d_name, ".") || !strcmp(direntSecond->d_name, "..") ){
// do nothing (straight logic)
} else {
secondFile = direntSecond->d_name;
if(strcmp(firstFile, secondFile) == 0){
printf("%s\n", secondFile);
}
}
}
}
}
printf("\n");
}
}
closedir(dir1);
return 0;
}