-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path源.cpp
92 lines (79 loc) · 1.51 KB
/
源.cpp
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
90
91
92
#include "md5.h"
#include "fileTree.h"
using namespace std;
/*
目录及子目录下,
不能有中文文件夹及文件!
不能有中文文件夹及文件!
不能有中文文件夹及文件!
*/
void compare(fileTree* father1,fileTree* father2)
{
fileTree* ptr1 = father1->sun;
fileTree* ptr2;
while (ptr1 != NULL)
{
bool ifFound = 0;
ptr2 = father2->sun;
while (ptr2 != NULL)
{
if (ptr1->fileName == ptr2->fileName)
{
ifFound = 1;
break;
}
ptr2 = ptr2->brother;
}
if (ifFound)
{
if(PathIsDirectoryA(ptr1->fileName.c_str()))//如果是文件夹,则递归
{
compare(ptr1, ptr2);
}
else //如果是文件,则比较md5值
{
if (ptr1->vue_md5 != ptr2->vue_md5)
cout << "修改点:" << ptr1->fileName << "-----" << ptr2->fileName << endl;
}
}
else
{
cout << "删除处:" << ptr1->fileName << endl;
}
ptr1 = ptr1->brother;
}
ptr2 = father2->sun;
while (ptr2 != NULL)
{
bool ifFound = 0;
ptr1 = father1->sun;
while (ptr1 != NULL)
{
if (ptr1->fileName == ptr2->fileName)
{
ifFound = 1;
break;
}
ptr1 = ptr1->brother;
}
if (!ifFound)
cout << "增加处:" << ptr2->fileName << endl;
ptr2 = ptr2->brother;
}
}
void main()
{
string filePath;
cout << "文件夹:" << endl;
cin >> filePath;
fileTree* root1,*root2;
root1 = nNode(0, "root", "");
findFile(filePath, root1);
cout << "输入任意字符以开始比较..." << endl;
int temp;
cin >> temp;
root2 = nNode(0, "root", "");
findFile(filePath, root2);
compare(root1, root2);
system("pause");
}