-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfileinfo.cpp
More file actions
35 lines (30 loc) · 817 Bytes
/
fileinfo.cpp
File metadata and controls
35 lines (30 loc) · 817 Bytes
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
#include "fileinfo.h"
#include <QDateTime>
FileInfo_S parseBySftpData(QString data) {
FileInfo_S info;
QList<QString> array;
for (auto d : data.split(" ")) {
if (!d.isEmpty()) {
array.append(d);
}
}
unsigned long timeS = array[0].toULong();
QDateTime time = QDateTime::fromSecsSinceEpoch(timeS);
QString updateTime = time.toString("yyyy-MM-dd hh:mm:ss");
info.updateTime = updateTime;
info.permission = array[1];
info.fileNum = array[2];
QString type = array[1].at(0);
if (type == "d") {
info.fileType = 1;
} else if (type == "-") {
info.fileType = 2;
} else if (type == "l") {
info.fileType = 3;
}
info.userOrGroup = array[3] + "/" + array[4];
info.fileSize = array[5];
auto names = array.mid(9);
info.fileName = names.join(" ");
return info;
}