-
Notifications
You must be signed in to change notification settings - Fork 1
/
folderchecksum.h
51 lines (43 loc) · 1.11 KB
/
folderchecksum.h
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
#ifndef FOLDERCHECKSUM_H
#define FOLDERCHECKSUM_H
#include <QString>
#include <QMap>
struct FileInfo
{
public:
quint32 size;
QString hash;
};
class FolderInfo : public QMap<QString, FileInfo>
{
QString _path;
public:
FolderInfo();
static FolderInfo *fromDir(const QString &path);
static FolderInfo *fromJson(const QByteArray &array);
QByteArray toByteArray();
private:
QString removePath(const QString &path);
void checkFolder(const QString &p);
void checkFile(const QString &p);
};
class FolderCheckSum
{
QString _path;
QMap<QString, QString> _checkSums;
QList<QString> _files;
public:
FolderCheckSum();
FolderCheckSum(QString path);
void calc();
QMap<QString, QString> checkSums() const;
QList<QString> files() const;
QByteArray toByteArray();
static FolderCheckSum *fromDir(const QString &path);
static FolderCheckSum *fromByteArray(const QByteArray &array);
private:
QString removePath(const QString &path);
void checkFolder(const QString &p);
QByteArray fileChecksum(const QString &fileName);
};
#endif // FOLDERCHECKSUM_H