diff --git a/app/scanner/mainwindow.cpp b/app/scanner/mainwindow.cpp index 2464fee9..024097c5 100644 --- a/app/scanner/mainwindow.cpp +++ b/app/scanner/mainwindow.cpp @@ -83,14 +83,17 @@ MainWindow::MainWindow(QWidget *parent) m_versionDll = new VersionDll; HGBase_RegisterCrashFunc(CrashFunc, this); -// HGChar logFilePath[512]; -// HGBase_GetLogFilePath(logFilePath, 512); -// deleteFile(QString::fromStdString(getStdString(logFilePath))); + HGChar logFilePath[512]; + HGBase_GetLogFilePath(logFilePath, 512); + deleteFile(QString::fromStdString(getStdString(logFilePath))); -// HGChar cfgFilePath[512]; -// HGBase_GetConfigPath(cfgFilePath, 512); -// deleteFile(QString::fromStdString(getStdString(cfgFilePath))); + HGChar cfgFilePath[512]; + HGBase_GetConfigPath(cfgFilePath, 512); + deleteFile(QString::fromStdString(getStdString(cfgFilePath))); + HGChar upgradeDpkgPath[512]; + HGBase_GetTmpPath(upgradeDpkgPath, 512); + deleteFile(QString::fromStdString(getStdString(upgradeDpkgPath))); #if defined(OEM_HANWANG) this->setWindowIcon(QIcon(":images/image_rsc/logo/Hanvon_logo1.ico")); @@ -3944,39 +3947,42 @@ QString MainWindow::getLogInfo(HGResult ret) return str; } -//void MainWindow::deleteFile(QString filePath) -//{ -// QDir dir(filePath); -// if(!dir.exists()) -// { -// return; -// } -// dir.setFilter(QDir::Files | QDir::NoSymLinks); -// QFileInfoList list = dir.entryInfoList(); +void MainWindow::deleteFile(QString filePath) +{ + QDir dir(filePath); + if(!dir.exists()) + { + return; + } + dir.setFilter(QDir::Files | QDir::NoSymLinks); + QFileInfoList list = dir.entryInfoList(); -// int count = list.count(); -// if(count <= 0) -// { -// return; -// } + int count = list.count(); + if(count <= 0) + { + return; + } -// for(int i=0; i < count; i++) -// { -// QFileInfo info = list.at(i); -// QString suffix = info.suffix(); -// if(QString::compare(suffix, QString("exe"), Qt::CaseInsensitive) == 0) -// { -// QDateTime nowTime = QDateTime::currentDateTime(); -// QDateTime createTime = info.created(); -// int days = createTime.daysTo(nowTime); -// if (days > 14) -// { -// HGBase_DeleteFile(info.absoluteFilePath().c_str()); -// } -// } - -// } -//} + for(int i=0; i < count; i++) + { + QFileInfo info = list.at(i); + QString suffix = info.suffix(); + if(suffix == "log") + { + QDateTime nowTime = QDateTime::currentDateTime(); + QDateTime createTime = info.created(); + int days = createTime.daysTo(nowTime); + if (days > 14) + { + HGBase_DeleteFile(info.absoluteFilePath().toStdString().c_str()); + } + } + else if(suffix == "exe") + { + HGBase_DeleteFile(info.absoluteFilePath().toStdString().c_str()); + } + } +} void MainWindow::on_scanOptions_changed(const QString &device, const QString &option, bool checked_now) { @@ -4081,7 +4087,7 @@ void MainWindow::on_actionact_update_triggered() HGBase_GetFileSuffix(url.toStdString().c_str(), suffix, 64); HGChar savePath[512]; - HGBase_GetConfigPath(savePath, 512); + HGBase_GetTmpPath(savePath, 512); HGBase_CreateDir(savePath); HGChar fileName[128]; diff --git a/app/scanner/mainwindow.h b/app/scanner/mainwindow.h index f6ad6f52..93bcda6e 100644 --- a/app/scanner/mainwindow.h +++ b/app/scanner/mainwindow.h @@ -265,7 +265,7 @@ private: bool isLimitAccessFolder(QString filePath); static QString GetDevType(const QString& fwVersion); void upgradeFwAndLockDevice(); -// void deleteFile(QString filePath); + void deleteFile(QString filePath); private: Ui::MainWindow *ui;