-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
md5maker.cpp
97 lines (89 loc) · 2.54 KB
/
md5maker.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
93
94
95
96
97
#include "md5maker.h"
#include "ui_md5maker.h"
#include <QDir>
#include <QString>
#include <QStringList>
#include <QFileDialog>
#include <QJsonObject>
#include <QJsonArray>
#include <QJsonDocument>
#include <QDesktopServices>
#include "file.h"
#include "MD5.h"
#include "QFile"
#include "Sandefine.h"
QString md5makerWorkPath;
md5maker::md5maker(QWidget *parent) :
QDialog(parent),
ui(new Ui::md5maker)
{
ui->setupUi(this);
}
md5maker::~md5maker()
{
delete ui;
}
void md5maker::on_pushButton_clicked()
{
QString dir;
string tem;
dir = QFileDialog::getExistingDirectory
(
this,
"空荧酒馆地图安装目录",
"./",
QFileDialog::ShowDirsOnly
);
tem =dir.toStdString();
qDebug()<<"目标路径"<<dir;
if(string(tem)=="")
{
qDebug()<<"空路径";
}else{
md5makerWorkPath=dir;
};
QStringList fileList;
file_search(md5makerWorkPath,fileList);
// qDebug()<<fileList;
QJsonArray allJson;
QJsonObject job;
for(int i=0;i<fileList.size();++i)
{
QFile file(fileList.at(i));
QJsonObject job2;
job2.insert("Length",file.size());
job.insert("data",job2);
job.insert("filePath",QString(fileList.at(i)).replace(md5makerWorkPath+"/",""));
job.insert("MD5",getFlieMD5(fileList.at(i)));
job.insert("version",MD5jsonVersion);
//qDebug()<<job;
allJson.push_back(job);
}
qDebug()<<allJson.size();
for (int a = 0; a < allJson.size(); ++a)
{
for(int b = 0; b < allJson.size()-1; ++b)
{
if(allJson.at(b).toObject()["data"].toObject()["Length"].toInt()
<
allJson.at(b+1).toObject()["data"].toObject()["Length"].toInt()
)
{
QJsonValue jovTemp;
jovTemp=allJson[b];
allJson[b]=allJson[b+1];
allJson[b+1]=jovTemp;
}
}
}
QJsonDocument doc;
doc.setArray(allJson);
QString str=QString::fromUtf8(doc.toJson(QJsonDocument::Compact).constData());
writeTXT(&str,
getTempPath("temp")+updaterTempDir+"MD5/",
"md5.json"
);
//qDebug()<<allJson;
ui->textBrowser->setText(str.replace("},{","}\r\n,\r\n{"));
//QDesktopServices::openUrl(QUrl(getTempPath("temp")+updaterTempDir+"MD5/md5.json"));
}