不打包空文件夹

CigaretteSH
Flamingo 9 months ago
parent 1ffc704984
commit 17bb01c5be

@ -345,21 +345,27 @@ void ExportDataThread::run()
QStringList argsNg; QStringList argsNg;
QStringList argsOk; QStringList argsOk;
zipFilePaths.append(g_conf_path.save_pics_path + "/" + "416_BJ_" + zipTimeStamp[0] + "-00_0.zip"); zipFilePaths.append(g_conf_path.save_pics_path + "/" + "416_BJ_" + zipTimeStamp[0] + "-00_" + zipTimeStamp[0] + "-59_0.zip");
zipFilePaths.append(g_conf_path.save_pics_path + "/" + "416_BJ_" + zipTimeStamp[0] + "-59_1.zip"); zipFilePaths.append(g_conf_path.save_pics_path + "/" + "416_BJ_" + zipTimeStamp[0] + "-00_" + zipTimeStamp[0] + "-59_1.zip");
fileList.append(g_conf_path.save_pics_path + "/" + zipTimeStamp[0] + "ng.txt"); fileList.append(g_conf_path.save_pics_path + "/" + zipTimeStamp[0] + "ng.txt");
fileList.append(g_conf_path.save_pics_path + "/" + zipTimeStamp[0] + "ok.txt"); fileList.append(g_conf_path.save_pics_path + "/" + zipTimeStamp[0] + "ok.txt");
zipTimeStamp.clear(); zipTimeStamp.clear();
QFile fileNg(fileList[0]); QFile* file[2] = { NULL };
QFile fileOk(fileList[1]);
fileNg.open(QIODevice::WriteOnly); file[0] = new QFile(fileList[0]);
fileOk.open(QIODevice::WriteOnly); file[1] = new QFile(fileList[1]);
QTextStream ngStream(&fileNg);
QTextStream okStream(&fileOk); //QFile fileNg(fileList[0]);
// QFile fileOk(fileList[1]);
file[0]->open(QIODevice::WriteOnly);
file[1]->open(QIODevice::WriteOnly);
QTextStream ngStream(file[0]);
QTextStream okStream(file[1]);
argsNg.append("a"); argsNg.append("a");
argsNg.append(zipFilePaths[0]); argsNg.append(zipFilePaths[0]);
@ -378,13 +384,6 @@ void ExportDataThread::run()
ngStream << listToZip[i] << endl; ngStream << listToZip[i] << endl;
} }
/*
QDir dir;
if (!dir.exists(listToZip[i].mid(index - 1)))
{
dir.mkpath(listToZip[i].mid(index - 1));
}
*/
} }
argsNg.append("-i@" + fileList[0]); argsNg.append("-i@" + fileList[0]);
argsNg.append("-mx=3"); argsNg.append("-mx=3");
@ -392,23 +391,26 @@ void ExportDataThread::run()
argsOk.append("-i@" + fileList[1]); argsOk.append("-i@" + fileList[1]);
argsOk.append("-mx=3"); argsOk.append("-mx=3");
fileNg.close(); file[0]->close();
fileOk.close(); file[1]->close();
for (int i = 0; i < zipFilePaths.size(); i++) { for (int i = 0; i < zipFilePaths.size(); i++) {
if (file[i]->size() == 0) {
continue;
}
process.start(QApplication::applicationDirPath() + "/7z.exe", i == 0 ? argsNg : argsOk); process.start(QApplication::applicationDirPath() + "/7z.exe", i == 0 ? argsNg : argsOk);
process.waitForStarted(); process.waitForStarted();
process.waitForFinished(); process.waitForFinished();
//QString out = QString::fromLocal8Bit(process.readAllStandardOutput()); //QString out = QString::fromLocal8Bit(process.readAllStandardOutput());
//qDebug() << out; //qDebug() << out;
remotePath = zipFilePaths[i].mid(zipFilePaths[i].indexOf("image") - 1); remotePath = zipFilePaths[i].mid(zipFilePaths[i].indexOf("image") - 1);
//qDebug() << remotePath; qDebug() << remotePath;
ConnectServer(zipFilePaths[i], remotePath); ConnectServer(zipFilePaths[i], remotePath);
QFile file(zipFilePaths[i]); QFile file(zipFilePaths[i]);
file.remove(); file.remove();
} }
fileNg.remove(); file[0]->remove();
fileOk.remove(); file[1]->remove();
listToZip.clear(); listToZip.clear();
readyToSendZip = false; readyToSendZip = false;
} }

Loading…
Cancel
Save