添加文件夹传输进度更新。
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QDirIterator>
|
||||
#include <QFileDevice>
|
||||
#include <QFileInfo>
|
||||
#include <QMutex>
|
||||
@@ -190,6 +191,33 @@ QString DirFileHelper::GetErr() const
|
||||
return QString();
|
||||
}
|
||||
|
||||
bool DirFileHelper::GetAllFiles(const QString& rootPath, QVector<QString>& files)
|
||||
{
|
||||
QDir rootDir(rootPath);
|
||||
|
||||
if (!rootDir.exists()) {
|
||||
qWarning() << "目录不存在:" << rootPath;
|
||||
return false;
|
||||
}
|
||||
|
||||
QString absoluteRootPath = rootDir.absolutePath();
|
||||
QDirIterator it(absoluteRootPath, QDir::Files | QDir::NoSymLinks | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
|
||||
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
QFileInfo fileInfo = it.fileInfo();
|
||||
if (fileInfo.isFile()) {
|
||||
QString absoluteFilePath = fileInfo.absoluteFilePath();
|
||||
QString relativePath = absoluteFilePath.mid(absoluteRootPath.length());
|
||||
if (relativePath.startsWith('/') || relativePath.startsWith('\\')) {
|
||||
relativePath = relativePath.mid(1);
|
||||
}
|
||||
files.append(relativePath);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
DirFileHelper::DirFileHelper(QObject* parent) : QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user