初步完成文件夹传输。

This commit is contained in:
2026-03-25 14:53:24 +08:00
parent 0e397ace7d
commit 7155880ff3
7 changed files with 290 additions and 54 deletions

View File

@@ -8,6 +8,12 @@
#include <QString>
#include <QVector>
struct FileStruct {
QString root;
QString mid;
QString relative;
};
struct PropertyData {
QString uuid;
QString command;
@@ -27,21 +33,40 @@ struct InfoMsg {
QString type;
quint64 size{};
quint32 permissions{};
QVector<QString> listSend;
QVector<QString> list;
QMap<QString, PropertyData> mapData;
FileStruct fst;
QMap<QString, QVector<FileStruct>> infos;
void serialize(QDataStream& data) const
{
data << mark << command << msg << fromPath << toPath << type << size << permissions;
data << static_cast<qint32>(listSend.size());
for (const auto& item : listSend) {
data << item;
}
data << static_cast<qint32>(list.size());
for (const auto& item : list) {
data << item;
}
data << static_cast<qint32>(mapData.size());
for (auto it = mapData.constBegin(); it != mapData.constEnd(); ++it) {
data << it.key();
data << it.value().uuid << it.value().command << it.value().userAction
<< it.value().localPath << it.value().remotePath << it.value().state << it.value().properE;
data << it.value().uuid << it.value().command << it.value().userAction << it.value().localPath
<< it.value().remotePath << it.value().state << it.value().properE;
}
data << fst.root << fst.mid << fst.relative;
data << static_cast<qint32>(infos.size());
for (auto it = infos.constBegin(); it != infos.constEnd(); ++it) {
data << it.key();
data << static_cast<qint32>(it.value().size());
for (const auto& fileStruct : it.value()) {
data << fileStruct.root << fileStruct.mid << fileStruct.relative;
}
}
}
@@ -50,6 +75,12 @@ struct InfoMsg {
data >> mark >> command >> msg >> fromPath >> toPath >> type >> size >> permissions;
qint32 listSize;
data >> listSize;
listSend.resize(listSize);
for (auto& item : listSend) {
data >> item;
}
data >> listSize;
list.resize(listSize);
for (auto& item : list) {
@@ -63,10 +94,28 @@ struct InfoMsg {
QString key;
PropertyData prop;
data >> key;
data >> prop.uuid >> prop.command >> prop.userAction >> prop.localPath
>> prop.remotePath >> prop.state >> prop.properE;
data >> prop.uuid >> prop.command >> prop.userAction >> prop.localPath >> prop.remotePath >> prop.state >>
prop.properE;
mapData.insert(key, prop);
}
data >> fst.root >> fst.mid >> fst.relative;
data >> mapSize;
infos.clear();
for (int i = 0; i < mapSize; ++i) {
QString key;
data >> key;
qint32 vectorSize;
data >> vectorSize;
QVector<FileStruct> fileVector;
fileVector.resize(vectorSize);
for (int j = 0; j < vectorSize; ++j) {
data >> fileVector[j].root >> fileVector[j].mid >> fileVector[j].relative;
}
infos.insert(key, fileVector);
}
}
};
QDataStream& operator<<(QDataStream& data, const InfoMsg& info);