From 166ed9fa8a78c00d58f2663baba84337f80c1001 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Mon, 8 Dec 2014 17:34:27 -0800 Subject: [PATCH] Add deleteTempLogFiles method --- src/comm/MAVLinkProtocol.cc | 12 ++++++++++++ src/comm/MAVLinkProtocol.h | 3 +++ 2 files changed, 15 insertions(+) diff --git a/src/comm/MAVLinkProtocol.cc b/src/comm/MAVLinkProtocol.cc index 3b583080c..71e3aa80a 100644 --- a/src/comm/MAVLinkProtocol.cc +++ b/src/comm/MAVLinkProtocol.cc @@ -757,3 +757,15 @@ void MAVLinkProtocol::suspendLogForReplay(bool suspend) _logSuspendReplay = suspend; } + +void MAVLinkProtocol::deleteTempLogFiles(void) +{ + QDir tempDir(QStandardPaths::writableLocation(QStandardPaths::TempLocation)); + + QString filter(QString("*.%1").arg(_logFileExtension)); + QFileInfoList fileInfoList = tempDir.entryInfoList(QStringList(filter), QDir::Files); + + foreach(const QFileInfo fileInfo, fileInfoList) { + QFile::remove(fileInfo.filePath()); + } +} diff --git a/src/comm/MAVLinkProtocol.h b/src/comm/MAVLinkProtocol.h index 070902b78..04da4a693 100644 --- a/src/comm/MAVLinkProtocol.h +++ b/src/comm/MAVLinkProtocol.h @@ -199,6 +199,9 @@ public slots: /// and not called directly in order to synchronize with the bytesReady signal /// which may be ahead of it in the signal queue. void suspendLogForReplay(bool suspend); + + /// @brief Deletes any log files which are in the temp directory + static void deleteTempLogFiles(void); protected: // Override from QObject -- 2.22.0